AnsweredAssumed Answered

Generating variable frequency PWM on SPC570s

Question asked by ThanhTung Nguyen on Sep 26, 2017

Dear All

I am trying to generate the variable frequency PWM on SPC570s following the documents

"SPC570Sx 32-bit Power Architecture® microcontroller for automotive ASILD applications" page 759 Usage of Compare Registers

I am using the dual compare registers COMP1 and COMP2 to generate variable frequency PWM. I always get problems "when changing COMP1 and COMP2 while the counter is active", the term  Use caution when changing COMP1 and COMP2 while the counter is active. If the counter has already passed the new value, it will count to 0xFFFF or 0x0000, roll over, then begin counting toward the new value. The check is: CNTR = COMPx,not CNTR > COMP1 or
That why I used CMPLD1 and CMPLD2 to pre-load the value of COMP1 and COMP2.

The problem is whenever I use interrupt to change (update new) frequency by changing CMPLD1 and CMPLD2. Although at the beginning, the PWM looks good, however, they do not become complementary PWM anymore when the Frequency is changed in interrupt.
Best Regards