AnsweredAssumed Answered

Unexpected Disabling of interrupt

Question asked by THANGADURAI A on Nov 20, 2009
Latest reply on Nov 23, 2009 by THANGADURAI A

In HCS08SG8 controller, I am using TPM2CH1 as a compare channel (- software interrupt only) to generate the MonoStable Output(OneShot signal). ie ON duration of the pulse is fixed and the off duration is undetermined. When ever iw want to generate the signal just i trigger the signal by switching on the port pin and load the timer for 1 ms. After the 1 ms, th eport pin will be switched off at the compare interrupt.

           From the datasheet i studied that there is a latchng mechanism to be taken care while writting the compare register. otherwise the compare register will not be wriiten ar per our expectation.

 

So i wrote code as below:

 

Main:

      if((System Input Conditions) && (InterruptStatus == DISABLED))

     {

          Switch ON the Port Pin;

 

          Enable the Compare Interrupt;

 

          /* Flag holding the status of Timer Interrupt */

          InterruptStatus = ENABLED;

 

          TPM1C1V = TPM1CNT + One Ms Equivalent Count;

     }

 

ISR:

   /* Interrupt Flag clearing mechanism */ 

  

      DummyVariable = TPM2CH1SC;

      TPM2CH1IF = 0;

 

      TPM2CH1IE = 1;

     

      InterruptStatus = ENABLED;

 }

 

 

 

 Thiw code works 99 %. But at 1 % the output signal has been stopped after some hours.

When i debug this, InterruptStatus Flag remains ENABLED but the actual interrupt enable bit in the hardware register was disabled.so signal genartor doesnt works after that time.

 

Could anyone encountered similar problems before? Did i make any mistake in my code?

 

 

Message Edited by TDKamalAru on 2009-11-20 05:09 AM

Outcomes