AnsweredAssumed Answered

ADuC7061 PWM update

Question asked by tcachat on Jan 5, 2016
Latest reply on Jan 8, 2016 by tcachat

Dear all,

 

We use a PWM output to produce a frequency signal that has to be updated regularly. We have observed an unexpected behavior. When we change the period to a lower one, sometimes the output is stalled for a very long time (apparently it counts until 0xFFFF). Here is a minimal code example using the Eval-ADuC7061MKZ :

 

 

int main(void)

{

    volatile unsigned long ulCpt = 0;

    #define CPT_DELAY    0x50500

 

    POWKEY1 = 0x1;

    POWCON0 = 0x78;           // Set core to max CPU speed of 10.24Mhz

    POWKEY2 = 0xF4;

  

    // Initialize the GPIO pins for PWM mode

    GP0CON0 = BIT16;          // Select PWM1 output

    PWMCON    = BIT7+BIT6 + BIT3 + BIT0;

  

    PWM0COM0 = 0xFFFF;        //    Configure PWM0 output high trigger time

    PWM0COM1 = 0xFFFF;        //    Configure PWM0 output Low trigger time

    PWM0COM2 = 0x80;        //    Configure PWM1 output low trigger time

    PWM0LEN = 0x100;        //    Configure PWM1 output high trigger time

    PWMCON    = BIT7 + BIT6 + BIT3 + BIT0;

 

    while (1)

    {

        for(ulCpt=0; ulCpt< CPT_DELAY; ulCpt++)

        {

        }

        PWM0COM2 = 0x1000;        //    Configure PWM1 output low trigger time

        PWM0LEN = 0x2000;        //    Configure PWM1 output high trigger time

        for(ulCpt=0; ulCpt< CPT_DELAY; ulCpt++)

        {

        }

        PWM0COM2 = 0x300;        //    Configure PWM1 output low trigger time

        PWM0LEN = 0x600;        //    Configure PWM1 output high trigger time

    }

}

 

Attached is a scope plot at P0_4 (PWM1 output). The trig is configured to detect a long pulse (either positive or negative, long periods would also be possible).

 

The LCOMP bit (BIT3) in PWMCON should avoid this problem, and we have tried many combination of setting/clearing it before/after changing the period, without success. So what is the meaning of the bit LCOMP?

 

It seems my question is related to https://ez.analog.com/message/152946#152946, but the part is not the same.

 

We have designed a board with an ADuC7060BSTZ32, that is now in production for some time and already used by our clients, where we use the pin P1.4/PWM2. So it seems impossible to use an interrupt to update the register at the right moment?

 

Regards

Attachments

Outcomes