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.

C2000WARE: Simultaneous writes to CMPA and TBPRD registers for variable frequency applications

Part Number: C2000WARE

Hi, an exerpt from the technical manual for the F2837xD device says: 

"For variable frequency applications, there is a need for simultaneous writes of TBPRD and CMPx registers between ePWM modules. This prevents situations where a CTR = 0 or CTR = PRD pulse forces a shadow to active load of these registers before all registers are updated between ePWM modules (resulting in some registers being loaded from new shadow values while others are loaded from old shadow values). To support this, an ePWM register linking scheme for TBPRD:TBPRDHR, CMPA:CMPAHR, CMPB:CMPBHR, CMPC, and CMPD registers between PWM modules has been added. For a particular ePWM module # A , user code writes “B+1”, to the linked register bit-field in EPWMXLINK. “B” is the ePWM module # being linked to (that is, writes to the ePWM module “B” TBPRD:TBPRDHR, CMPA:CMPAHR, CMPB:CMPBHR, or CMPC will simultaneously be written to corresponding register in ePWM module “A”). For instance if ePWM3 EPWMXLINK register is configured so that CMPA:CMPAHR are linked to ePWM1, then a write to CMPA:CMPAHR in ePWM 1 will simultaneously write the same value to CMPA:CMPAHR in ePWM3. If ePWM4 also has its CMPA:CMPAHR registers linked to ePWM1, then a write to ePWM 1 will write the same value to the CMPA:CMPAHR registers in both ePWM3 and ePWM4. The register description for EPWMXLINK clearly explains the linked register bit-field values for corresponding ePWM."

First of all, does this mean that we need to initialise a new PWM module solely for the purpose of simultaneous loading of these two registers?

Is there any example at all in C2000Ware, preferably with direct register access method, which shows how to do this SIMULTANEOUSLY? 

If the CPU is executing instruction from top to bottom, the only way to simultaneously update these registers would be through the use of a CLA, or something that runs in parallel with the CPU?

Here is some code I have in an ISR which receives a modulation signal from the remote CPU which executes it's CLA which uses a DF22 control law and passed the info back to CPU1. I then bound the error signal and modulate the registers in a very simplistic fashion:

"

interrupt void ipc0_isr(void)
{
// Read IPC reply from the remote CPU and write to variable
collectorMod = (Uint16) IpcRegs.IPCREMOTEREPLY; // Read data on IPC ADDR register

// Bound the returned control value to between 1 and 2.1
// Gives the minimum and maximum frequency bounds
if(collectorMod < 1)
{
collectorMod = 1;
}

if(collectorMod > 2.1)
{
collectorMod = 2.1;
}

// Scale modulation output according to the minimum switching frequency
collectorMod = collectorMod*RES_PERIOD_MAX;

// Modulate the TBPRD register of the resonant converter
// We need to write CMPA and TBPRD simultaneously, using the PWM linker method outlined in the PDF document... not done here
RES_PERIOD = collectorMod;
EPwm4Regs.CMPA.bit.CMPA = RES_PERIOD/2; // CMPA sets duty cycle

// Return from interrupt
IpcRegs.IPCACK.bit.IPC0 = 1; // Clear IPC0 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge PIE group 1 to enable further interrupts

}

"

What would I need to add to this exerpt to enable the simultaneous writes to both registers rather than the way I have it laid out now?

Thanks in advance!
Joel

  • Hi Joel,

    The first sentence from the excerpt is very important, "simultaneous writes of TBPRD and CMPx registers between ePWM modules". What this is trying to say is you want TBPRD and CMPx to be updated at the same time across modules not necessarily update TBPRD and CMPx within the same ePWM module.

    First of all, does this mean that we need to initialise a new PWM module solely for the purpose of simultaneous loading of these two registers?

    For any modules that you would like to link (for simultaneous TBPRD and CMPx updates) you will have to initialize, yes.

    Is there any example at all in C2000Ware, preferably with direct register access method, which shows how to do this SIMULTANEOUSLY? 

    There are no examples at the moment that utilize this linking feature, but this can be accomplished by configuring the EPWMXLINK for each of the modules you would like to link. Lets say for example you plan to write the new values to EPWM1, and you want to update EPWM2, EPWM3, and EPWM4 at the same time. In this case you can configure EPWM2's EPWMXLINK to be linked to EPWM1 and the same for EPWM3 and EPWM4.

    What would I need to add to this exerpt to enable the simultaneous writes to both registers rather than the way I have it laid out now?

    If you configured the linking within your initialization then all you need to do is update the value for TBPRD and CMPx for the main module. All of the other modules will get updated TBPRD and CMPx values when shadow to active loading occurs, if you enabled shadow loading, if not this will happen immediately.

    Best Regards,

    Marlyn

  • Hi Marlyn - 


    Interesting, thank you for this response. In my case, I have two converters that operate in parallel - one runs at 1MHz and the other runs at 200-400kHz, but there is no need to synchronise them... would I still need to "synchronise" the EPWM clocks across these modules even if they operate at vast different frequencies, and if so, will I need to use this linking feature?

    The PWM of these two parallel converters should run independently and don't really need to have knowledge of each others outputs/inputs..

    Best wishes,

    Joel

  • Hi Joel,

    The PWM of these two parallel converters should run independently and don't really need to have knowledge of each others outputs/inputs..

    If the two pwm modules are intended to run independently then you don't have to synchronize them. Usually what we advice is that you use TBCLKSYNC to start their time base counters at the same time. Information on this can be found within the "Time-Base Clock Synchronization" section of the technical reference manual. Our software examples implement this so you could reference how to do this within the examples too.

    If you did want to synchronize them at some point then you should use the Time-Base Counter Synchronization scheme that is found within the "Time-Base Counter Synchronization" section within the technical reference manual. This will allow you to add a phase shift between the modules since you mentioned they are running at different frequencies.

    Best Regards,

    Marlyn