This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069: PWM generation

Part Number: TMS320F28069

I am using TMS320F28069 for the control of a power converter and I need two PEM signals, one of which is twice the frequency of the other. I am facing an issue with updating both the PWM signals (their CMPA registers) at the same time, because this register is updated at CTR = PRD which is different for the two signals. Is there a way to synchronize this such that both the registers are updated at CTR = PRD of the low frequency signal?

  • Saad,

    there is not a built in feature to updated 2 PWMs on the on the lower frequency PWM's CTR=PRD.

    Try this:   Configure the PWMs to have an interrupt on TBCTR = PRD, in the middle of the cycle(of the slower PWM) the faster PWM will have an interrupt, try updating both CMPA values using the shadow registers in this interrupt. I think this will get you the desired result.

    If that doesn't create the desired effect you should be able to synchronize this in software using some simple variables. Simply create a variable that will block writes the CMPA during the first half of the slower PWM, you can update this variable in the PWM's ISRs.

    Regards,
    Cody 

  • I tried doing that. It works. Now I am running into another issue. When I am writing to the EPWM registers in that ISR, each write operation is taking at least 4 instructions. e.g. 

     EPwm1Regs.CMPA.half.CMPA = X; has the following assembly:

    008025: 761F0280 MOVW DP, #0x280

    008027: 921B MOV AL, @0x1b
    008028: 761F01A0 MOVW DP, #0x1a0
    00802a: 9609 MOV @0x9, AL

    Can we reduce this number of instructions for each EPWM write?

  • Hi Saad,

    ".bit" and ".half" instructions are always going to perform a Read-Modify-Write sequence which is what you are seeing there. You should be able to reduce the number of instructions by using the ".all" write instead and write to the whole register.

    Regards,
    Kris