Good morning~all
I am measuring QEA and QEB of DSPIC30F2010 with the frequency 100KHz. The wave is perfect,there are no attenuation and distortion. A up-pull resistor--4.7k is connected with INDX pin. The outside ossilator of DSPIC30F2010 is passive crystals 6MHz. The inside initialization program is given below:
_FOSC(XT_PLL16 & PRI & CSW_FSCM_OFF); /configure inside clock 6M*16
_FWDT(WDT_ON & WDTPSB_2);
_FBORPOR(MCLR_EN & PWRT_OFF);
_FGS(CODE_PROT_OFF);
QEI initialization is as following:
ADPCFG |= 0x0038; // configure QEI pin as digital input
QEICONbits.QEIM = 0; // ban QEI mode
QEICONbits.CNTERR = 0; // clear any caculating error
QEICONbits.QEISIDL = 0; // keep working during dormancy
QEICONbits.SWPAB = 0; // don’t exchange QEA and QEB
QEICONbits.PCDOUT = 0; // I/O pin operate normally
QEICONbits.POSRES = 0; // Index pulse are no longer a location counter
QEICONbits.TQCS = 0;
QEICONbits.TQCKPS = 0;
//QEICONbits.TQGATE = 1;
//QEICONbits.UPDN_SRC = 1;
DFLTCONbits.CEID = 1; // ban counting error interruption
DFLTCONbits.QEOUT = 1; // QEn pin enable digital filter output
DFLTCONbits.QECK = 0; // Set QEn digita filter to be 1:1 clock frequency
//DFLTCONbits.INDOUT = 1; // enable index digital filter output pin
//DFLTCONbits.INDCK = 4; // set index digital filter to be 1:64 clock frequency
POSCNT = 0; // Reset the location counter
MAXCNT=0xffff;
QEICONbits.QEIM = 5; // X2 mode,reset location counter by Max
IEC2|=256;
The DSPIC30F2010 datasheet: http://www.kynix.com/uploadfiles/pdf0125/DSPIC30F2010-20E2fMM_65019.pdf
Now my problems are as following:
1). The POSCNT of the location counter is about 6668 when 10000 frequency sent by test module belong to signals between A and B.However,every value is not fixed.The right value of POSCNT should be 20000 and the mode is X2.
2)I have check the digital filter which in QEI inside.However the POSCNT didn’t change even I banned digital filter output.
Can anyone help me?
I’ll appreciate it if you could give me some help.