Hello all,
on my current project I need to use the quadrature decoder (QDEC) present in the XMEGA microcontrollers.
searching the web, I've found the application note AVR1600 and respective software, with that I've tried to initialize the module as follows:
QDEC_Total_Setup( &PORTB, /*PORT_t * qPort*/
6, /*uint8_t qPin*/
false, /*bool invIO*/
0, /*uint8_t qEvMux*/
EVSYS_CHMUX_PORTB_PIN6_gc, /*EVSYS_CHMUX_t qPinInput*/
false, /*bool useIndex*/
EVSYS_QDIRM_00_gc, /*EVSYS_QDIRM_t qIndexState*/
&TCC0, /*TC0_t * qTimer*/
TC_EVSEL_CH0_gc, /*TC_EVSEL_t qEventChannel*/
0); /*uint8_t lineCount*/
and then read from the counter as follows:
while(1){
PORTA.OUTTGL=PIN0_bm;
delay_ms(500);
printf("Counts %u\r",TCC0.CNT);
}
unfortunately the count numbers is always 0.
I've tried to initialize the registers manually like this :
PORTB.DIRCLR = (PIN6_bm | PIN7_bm);
PORTB.PIN6CTRL = PORT_ISC_LEVEL_gc;
PORTB.PIN7CTRL = PORT_ISC_LEVEL_gc;
EVSYS.CH0MUX = EVSYS_CHMUX_PORTB_PIN6_gc;
EVSYS.CH0CTRL = EVSYS_QDIRM_11_gc | EVSYS_QDEN_bm | EVSYS_DIGFILT_1SAMPLE_gc;
TCC0.CTRLD = (TC_EVSEL_CH0_gc | TC_EVACT_QDEC_gc);
TCC0.PER = 7;
TCC0.CTRLA = TC_CLKSEL_DIV1_gc;
with the same results.

I'm using PB6 e PB7 on a atxmega128a3u at 32MHz. the encoder signals are ok as can be seen here:

any help would be appreciated!
Thanks in advanced,
Best regards, Mauro.