AnsweredAssumed Answered

S08 Capture Mode and Timer Queries.

Question asked by pawan kumar on Aug 12, 2015
Latest reply on Dec 18, 2015 by Leojunin

Hi Friends,


Am using the MC9S08DZ60 eval board. I would like to do the following.


Capture a Rising edge-->Start a Timer of 32ms--> On Overflow, run a couple of statements in an ISR.


This is similar to the Pulse Accumulator in HC11 controllers.


My Assumption :


Timer and Capture mode are not related. Reason :

Wrote a program with capture mode disabled. Timer automatically starts and goes on as soon as it is initialized. Is this correct?


My Query :


I decided to initialize the Timer inside the ISR of Rising Edge Capture. So, baby step,  wrote a simple program to Capture only Rising Edges, but the ISR is being called in both Rising and falling Edges. Here's the code. (Your Advice on this approach also is required)


void inittimer(void)


TPM1MODL = 0x40;

TPM1MODH = 0x1F;

TPM1C1SC = 0x40;

TPM1C1SC_ELS1A=1; //Rising Edge capture






interrupt  VectorNumber_Vtpm1ch1 void timeredge(void)


  char temp1;


  sendstr("Rising Edge \r\n");


  printf("%d \r\n",counter);



  ping4=~ping4; //Toggle a GPIO to monitor with a scope.

  led2=~led2; //Toggle LED




volatile static int counter; //Defined before main().


I am sure there's no debouncing. I am Observing the TPM1Channel1 Pin on scope, which I have pulled up to 5V through a 2.5K resistor. I use a wire from ground to bring the pin low when required. I get beautiful square waves with no noise.


Please guide me on any of the 2 ways, so that I can Proceed further.