Cho mình hỏi về cách thiết lập module QEI trong 30f4011,nhận xung encoder 2 pha từ động cơ.encoder của mình không có chân INDEX.
Mình thiết lập như thề này nhưng vẫn chưa đọc đuoc POSCNT
Ai biết thì chỉ dùm mình nhé.
Code:
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
}