S12X Timer Issue

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

S12X Timer Issue

884 Views
vishaka_maithil
Contributor I

Hello experts,

                       I have a problem with Input capture on  mc9s12xs128  (a proto board with crystal frequency of 16MHz) controller.Iam trying to capture signals from a function generator on two input capture channels. The registers for capturing are configured in steps as below

 

  • Timer overflow enabled and Timer prescalar set to 8 (i.e.timer clock=Busclock/8)
  • Input capture channels selected
  • Capture on rising edges only
  • Clear the flags(TFLG1)
  • Enable the timer

ISR pending, timer overflow below a specific frequency, min value issues have been handled in the program. My problem is, when  my initial frequency(min frequency) is set, the output values do not show up.

 

I have another program where I have CAN messages to be published.I shall acquire the above signals and publish the output values on the CAN bus. CAN bus is also running on 16Mhz crystal with 250K baud. This time the output values do not run at all. What could be the poblem, unable to trace. Iam attatching my program , any quick response is highly appreciable.

Thanx in advance 

Labels (1)
0 Kudos
3 Replies

372 Views
kef
Specialist I

Why don't you test and debug separate components of your software? I doubt someone will find it interesting to waste ftime looking for all issues for you? Quick scan revealed two of them, and that's enough for me.

 

   TFLG1_C5F   = 1;
 

^^ this is WRONG. You are clearing all timer flags here, not just C5F.TFLG1 = TFLG1_C5F_MASK clears just C5F.

 

You have defined unsigned char txbuff[7]; and other arrays, but are accessing not existing 7th element of txbuff, while top index is 6.

 

0 Kudos

372 Views
vishaka_maithil
Contributor I

Hi Kef,

 

 I did test the components individually. Digital signals are working fine without CAN integration in it but when combined with CAN, digital signal counters are running but not the variable updation.

When I run the program, or set a breakpoint at the timer channel interrupt, it stops at delay counter. I think there is an issue with the delay counter n if I sont include the delay at all, the program stops at while loop (wait for transmission complete).

and,

 I am clearing the specific channel's flag by writing a 1 to C5F bit of TFLG1 register and not all the flags. If thats so, I have cleared all flags of TFLG1 by writing 0xFF to it in the ECT initialization. 

You are correct that I have defined an array of txbuff but not able to access the 7th element of it.I will look into it.

 

Hope you got me clearly this time.

Thank you.

 

 

0 Kudos

372 Views
kef
Specialist I
  • I am clearing the specific channel's flag by writing a 1 to C5F bit of TFLG1 register and not all the flags.

 

NO! TFLG1_C5F = 1 clears ALL flags in TFLG1 register. The effect of TFLG1_C5F=1 is the same like TFLG1 = 0xFF.Why? - Search the forum. I have explained it N times already.

0 Kudos