S12X Pulse Accumulator Troubles

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12X Pulse Accumulator Troubles

791 Views
jamienicol
Contributor I

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.

Labels (1)
0 Kudos
Reply
4 Replies

600 Views
kef
Specialist I

Port T pins are ECT pins, not TIM pins. S12XE has both TIM, and ECT timers, but connected to different ports.

0 Kudos
Reply

600 Views
jamienicol
Contributor I

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?

0 Kudos
Reply

600 Views
kef
Specialist I

By default TIM is routed to port R, not P. Use PTRRR to route TIM pins to port P.

0 Kudos
Reply

600 Views
jamienicol
Contributor I

Thank you! It works!

0 Kudos
Reply