Dave Haberek

MC9S08DZ60 TPMxCnSC unexpected interrupts

Discussion created by Dave Haberek on Oct 8, 2008
Latest reply on Oct 12, 2008 by donw
I set the TPMxCnSC register to send an interrupt for both rising and falling edges for my hall sensor inputs.  Problem is that I am getting interrupts when the motor is not moving (i.e., hall sensors are not changing).  I initialize TPM1C0SC = 0x4C (CH0IE, ELS0B, ELS0A are set).  My interrupt routine looks like this (I have a second routine for the other hall sensor).
 

@interrupt void tpm1_ch1_intr( void ) /* hall2 */
{
TPM1C1SC;
TPM1C1SC
= 0x4C;

timeStampHS1
= TPM1C1V;
Icu_TimestampNotifyHallSensor_1();
}

Now here is some more important information.  I only get the unexpected interrupts when the hall sensor is high.  Also, during other processing in the temporal loop, the interrupts are disabled, some processing is done, then the interrupts are enabled again, with the following functions.

void disable_hall_effects( void )
{
INTERRUPTS_OFF();

TPM1C0SC;
TPM1C0SC
= 0; /* timer 1 chan 0 status/ctrl */ /*Input capture for Hall effects*/

TPM1C1SC;
TPM1C1SC
= 0; /* timer 1 chan 1 status/ctrl */ /*Input capture for Hall effects*/

INTERRUPTS_ON();
}

void

enable_hall_effects( void )
{
INTERRUPTS_OFF();

TPM1C0SC;
TPM1C0SC
=
0x4C; /* timer 1 chan 0 status/ctrl */ /*Input capture for Hall effects*/

TPM1C1SC;
TPM1C1SC
= 0x4C; /* timer 1 chan 1 status/ctrl */ /*Input capture for Hall effects*/

TPM1SC;
TPM1SC = (T1_PRESCALE | T1_BUS_CLOCK); /* timer 1 status/ctrl register Turn the timer on*/

INTERRUPTS_ON();

}

So I am wondering if the disable/enable actions are causing an interrupt to be sent.  Any other ideas?  Thanks!

Dave

 

Outcomes