Qei module 18f4431
Posted: 17 Jun 2011 01:37
Hi everybudy,
I working pic18f4431 with a omron encoder 600p/r two phase with 4 edges read
I made a program from the interrupt routine an reach 50khz reading. Not bad, but not enough.
I have read in the spec there is a QEI MODULE can do it faster.
I look for a example of the minimun configuration to read possition an speed
I find the GS002.pdf from Microchip
void InitQEI(void)
{
ADPCFG |= 0x0038; // Configure QEI pins as digital inputs
QEICONbits.QEIM = 0; // Disable QEI Module
QEICONbits.CNTERR = 0; // Clear any count errors
QEICONbits.QEISIDL = 0; // Continue operation during sleep
QEICONbits.SWPAB = 0; // QEA and QEB not swapped
QEICONbits.PCDOUT = 0; // Normal I/O pin operation
QEICONbits.POSRES = 1; // Index pulse resets position counter
DFLTCONbits.CEID = 1; // Count error interrupts disabled
DFLTCONbits.QEOUT = 1; // Digital filters output enabled for QEn pins
DFLTCONbits.QECK = 5; // 1:64 clock divide for digital filter for QEn
DFLTCONbits.INDOUT = 1; // Digital filter output enabled for Index pin
DFLTCONbits.INDCK = 5; // 1:64 clock divide for digital filter for Index
POSCNT = 0; // Reset position counter
QEICONbits.QEIM = 6; // X4 mode with position counter reset by Index
return;
}
I'll that but the compiler dont accept all line.
Help me please
Thanks
ccfred
I working pic18f4431 with a omron encoder 600p/r two phase with 4 edges read
I made a program from the interrupt routine an reach 50khz reading. Not bad, but not enough.
I have read in the spec there is a QEI MODULE can do it faster.
I look for a example of the minimun configuration to read possition an speed
I find the GS002.pdf from Microchip
void InitQEI(void)
{
ADPCFG |= 0x0038; // Configure QEI pins as digital inputs
QEICONbits.QEIM = 0; // Disable QEI Module
QEICONbits.CNTERR = 0; // Clear any count errors
QEICONbits.QEISIDL = 0; // Continue operation during sleep
QEICONbits.SWPAB = 0; // QEA and QEB not swapped
QEICONbits.PCDOUT = 0; // Normal I/O pin operation
QEICONbits.POSRES = 1; // Index pulse resets position counter
DFLTCONbits.CEID = 1; // Count error interrupts disabled
DFLTCONbits.QEOUT = 1; // Digital filters output enabled for QEn pins
DFLTCONbits.QECK = 5; // 1:64 clock divide for digital filter for QEn
DFLTCONbits.INDOUT = 1; // Digital filter output enabled for Index pin
DFLTCONbits.INDCK = 5; // 1:64 clock divide for digital filter for Index
POSCNT = 0; // Reset position counter
QEICONbits.QEIM = 6; // X4 mode with position counter reset by Index
return;
}
I'll that but the compiler dont accept all line.
Help me please
Thanks
ccfred