ATxmega64A3 Capture TCD0.CCA problem
2011-07-27 by warm38spl
I am using TDC0 to time an incoming event. At time 1 I set TDC0.CNT = 0x0000; TCD0.CCA = 0x0000; TCD0.PER = 0x065F; TCD0.CTRLA = TC_CLKSEL_DIV1_gc; EVENT0 is supposed to capture the CNT into CCA when PortB pin1 signall is Rising. I have added an overflow function (which is why "TCD0.PER = 0x065F;") in case there is no signal coming in and I set everything to defaults. With no signal coming in (results are set to defaults). at time 1 TDC0.CNT = 0x0000 TCD0.CCA = 0x00 TCD0.PER = 0x065F TDC0 set to TC_CLKSEL_DIV1_gc at time 2 TDC0.CNT = 0x0254 TCD0.CCA = 0x00 at time 3 TDC0.CNT = 0x03ce TCD0.CCA = 0x00 When TCD0 hits the overflow interrupt TDC0.CNT = 0x0043 TCD0.CCA = 0x00 TCD0.PER = 0x065f TDC0 set to TC_CLKSEL_OFF_gc At end of Cycle TDC0.CNT = 0x00b3 TCD0.CCA = 0x00 Now if I send in a pulse that causes Event0 (PortB1 rising) to capture the count this is what I get at time 1 TDC0.CNT = 0x0000 TCD0.CCA = 0x00 TCD0.PER = 0x065F TDC0 set to TC_CLKSEL_DIV1_gc at time 2 TDC0.CNT = 0x0255 TCD0.CCA = 0x00 at time 3 TDC0.CNT = 0x03cf TCD0.CCA = 0x8260 (varies up to 8295) When TCD0 hits the overflow interrupt TDC0.CNT = 0x003d TCD0.CCA = 0x8260 TCD0.PER = 0x065f TDC0 set to TC_CLKSEL_OFF_gc At end of Cycle TDC0.CNT = 0x00ad TCD0.CCA = 0x8260 Why the HUGE number in CCA? I would think it to be around 0x0420 from tests on a previous system (using a 16A4). If I add 0x7FFF to the 0x8260 then it looks like a sane/reasonable number for what I expecting. So why is it so weird? Is there something I'm doing wrong in my set up? Before there was no Overflow in TCD0. Is there a problem with having a Capture and Overflow in the same timer? I tried moving the Overflow out and doing the overflow processing on TCE1, but TCD0 is still out of it. wade