I'm trying to count pulses on an input pin using the pulse accumulator, but it's always saying there have been no pulses. I'm using a MC9S12XEP100. My initialisation code is this:
TIM_PACTL_PAEN = 1;
TIM_PACTL_PAMOD = 0;
TIM_PACTL_PEDGE = 1;
DDRT_DDRT7 = 0;
and I'm inputing a 1kHz square wave into PT7. but TIM_PACNT is always 0.
reading through the datasheet I think I read that I should add the code
TIM_TIOS_IOS7 = 1;
TIM_TCTL1_OM7 = 0;
TIM_TCTL1_OL7 = 0;
TIM_OC7M_OC7M7 = 0;
but I don't understand why. And it doesn't fix anything anyway.
Am I missing something? Thanks in advance.
Port T pins are ECT pins, not TIM pins. S12XE has both TIM, and ECT timers, but connected to different ports.
So it's TIMIOC7 rather than IOC7, ie Port P not T.
Still, I updated the code and switched my input signal to the correct pin and still no luck. Any other ideas?
By default TIM is routed to port R, not P. Use PTRRR to route TIM pins to port P.
Thank you! It works!