AnsweredAssumed Answered

TPM1MOD PWM abnormal

Question asked by KONSTANTINOS HALAKATEVAKIS on Jul 30, 2013
Latest reply on Aug 2, 2013 by KONSTANTINOS HALAKATEVAKIS

Hello,

 

In one of our products we use the MC9S08SE4 microcontroller.

We have noticed that when we change the PWM period (TPM1MOD) in the timer overflow interrupt (Vtpm1ovf),

there are two PWM periods until next overflow interrupt.

 

Our code sample - in order to reproduce this issue - is:

 

unsigned int TPM1MOD_BUF;

 

void main(void)

{

    TPM1MOD = 500;

    TPM1CNTH = 0;

    TPM1C0SC = 0x28;

    TPM1C0V = 250;

    TPM1SC = 0x4B;

 

 

    EnableInterrupts;

 

 

    for(;;)

    {

        __RESET_WATCHDOG();

    }

 

}

 

interrupt VectorNumber_Vtpm1ovf void isr_Vtpm1ovf(void)

{

   

    TPM1SC;

    TPM1SC_TOF = 0;

    TPM1MOD_BUF = TPM1MOD;

    TPM1MOD_BUF += 100;

    TPM1MOD = TPM1MOD_BUF;

    TPM1MOD_BUF >>= 1;

    TPM1C0V = TPM1MOD_BUF;

    TPM1C1V = TPM1MOD_BUF;

 

}

 

Do you know why is this happening?

 

Thanks in advance.

Outcomes