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.

TMS320F28379D: How to align the hardware triggers from 2 CPUs of TMS320F28379D

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

I have implemented a code that uses 2 CPUs of TMS320F28379D, and created a program that arranges from ePWM1 to ePWM4 on the CPU1 side and arranges from ePWM5 to ePWM8 on the CPU2 side.
I set to output the hardware interrupt set for Second Event from ePWM3 and ePWM7, but every time the microcomputer is operated, the event occurrences are aligned or shifted by half a cycle.
I want to align the events of CPU1 and CPU2, what should I do?

  • Hi Kunihide,

    Can you please describe what kind of trigger you are trying to align? Providing some code for this part would also be helpful in understanding how things are setup.

    Best Regards,

    Marlyn

  • Hello Merlin

    Create an executable file for each of CPU1 and CPU2, and generate PWM pulses that are synchronized from ePWM1 to ePWM8 and operated at the same frequency.
    However, the phases of ePWM1 to ePWM4 and ePWM5 to ePWM8 are fixed and out of phase.
    ePWM1 and ePWM2 set a trigger for ADC capture and control writing from ePWM3 to the shadow memory of ePWM1 to ePWM4. Similarly, writing from ePWM7 to the shadow memory of ePWM5 to ePWM8 is controlled.
    This is because it uses a setting that issues a hardware interrupt at half the PWM frequency.
    The reason why writing to the shadow memory is controlled by the hardware interrupt is that if the result calculated in the hardware interrupt is set to the shadow memory as it is, the timing of reflection is changed depending on the calculation load.
    The phase is matched by the PHS setting, but the trigger output shifts or shifts at the same time each time the microcomputer is started.

    I set CPU1 and CPU2 to operate at the same time on the CCS settings and tried to execute them, but even with this, the interrupt pattern of the hardware interrupt changed every time the microcomputer was started.

  • Hi Kunihide,

    I set CPU1 and CPU2 to operate at the same time on the CCS settings and tried to execute them, but even with this, the interrupt pattern of the hardware interrupt changed every time the microcomputer was started.

    Are you using the GBCLKSYNC bit instead of the TBCLKSYNC bit to start all of your pwm waveforms at the same time? If not, I would highly encourage you to do this. GBCLKSYNC will start the time base counter for all of the enabled pwm modules for both CPU1 and CPU2.

    Best Regards,

    Marlyn

  • Hi Marlyn

    I found a description of the function pointed out in 15.4.3.2 Time-Base Clock Synchronization of the Technical Reference Manual (Rev. I).
    I will tell the person in charge and check it.

  • Hi Marlyn

    When I checked the initialization code of CPU1 and CPU2, I found that the procedure of "15.4.3.2 Time-Base Clock Synchronization" was repeated for each module with the following structure.

    // Excerpt of initialization code
    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM1 = 1;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    // ePWM1 initialization code

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM2 = 1;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    // ePWM2 initialization code

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM3 = 1;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    // ePWM3 initialization code

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM4 = 1;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    // ePWM4 initialization code

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;

  • Hi Kunihide,

    For the epwm modules to start at the same time across the different cores you'll need to use GTBCLKSYNC (Global Time Base Clock Sync). The procedure would look like the below:

    CPU1 Flow:

    GTBCLKSYNC = 0;

    Configure PWMs for CPU1

    waitForCpu2ReadySignal(); // IPC message coming from CPU2

    GTBCLKSYNC = 1;

    CPU2 Flow:

    Configure PWMs for CPU2

    sendReadySignalToCPU1(); // IPC message to CPU1

    Best Regards,

    Marlyn

  • Hi Marlyn

    It is implemented as follows with reference to the code that was uploaded.
    When I try to check if it can be built, it seems that the path of "waitForCpu2ReadySignal ()" does not pass and an error occurs.
    In what file is waitForCpu2ReadySignal implemented?
    The compiler version and code use the following.
    soft Version: 8.3.1.00004

    compiler version: TI v16.9.2.LTS
    Code: controlSUITE \ device_support \ F2837xD \ v190
    The code I'm trying to implement is:

    <CPU1>

    EALLOW;

    /*CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0; */

    CpuSysRegs.PCLKCR0.bit.GTBCLKSYNC = 0;
    CpuSysRegs.PCLKCR2.bit.EPWM1 = 1;
    EDIS;

    // ePWM1 initialization code
    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM2 = 1;
    EDIS;
    // ePWM2 initialization code
    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM3 = 1;
    EDIS;

    // ePWM3 initialization code
    EALLOW;

    CpuSysRegs.PCLKCR2.bit.EPWM4 = 1;
    EDIS;

    // ePWM4 initialization code
    waitForCpu2ReadySignal(); // IPC message coming from CPU2

    EALLOW;
    /*CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1; * /
    CpuSysRegs.PCLKCR0.bit.GTBCLKSYNC = 1;
    EDIS;
    <CPU2>

    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM5 = 1;

    EDIS;

    // ePWM5 initialization code
    EALLOW;

    CpuSysRegs.PCLKCR2.bit.EPWM6 = 1;
    EDIS;

    // ePWM6 initialization code
    EALLOW;

    CpuSysRegs.PCLKCR2.bit.EPWM7 = 1;
    EDIS;

    // ePWM7 initialization code
    EALLOW;

    CpuSysRegs.PCLKCR2.bit.EPWM8 = 1;
    EDIS;

    // ePWM8 initialization code

    EALLOW;
    CpuSysRegs.PCLKCR2.bit.EPWM9 = 1;
    EDIS;


    // ePWM9 initialization code
    sendReadySignalToCPU1(); // IPC message to CPU1
  • Hi Marlyn

    I made a tentative model because I don't know the location of the "waitForCpu2ReadySignal" and "sendReadySignalToCPU1" functions.
    I have already assigned some CHANNEL for CPU-to-CPU communication, so I put in a code to send information to a free CHANNEL.
    However, even if I added a code to set "GTBCLKSYNC = 1" after communication between CPUs, as a result of checking from CCS, Falg did not change.
    The added code is as follows.

    // CPU1 side receiver
    loopCond = true;
    while (loopCond) {
    MW_IPC_Receive (CHANNEL3, (uint32_t *)& TestModel.IPCReceive_o1_Channel3, & TestModel.IPCReceive_o2_Channel3, 1, 5, 0);

    loopCond =! TestModel.IPCReceive_o1_Channel3;
    }


    CpuSysRegs.PCLKCR0.bit.GTBCLKSYNC = 1;

    // CPU2 side transmitter
    Initial_Complete_Value = 1;
    MW_IPC_Transmit (CHANNEL3, (uint32_t *) & Initial_Complete_Value, 1, 5, 0);

  • Hi Kunihide,

    My apologies, I should have stated that those functions were just pseudo functions.

    What I meant was something like the following code:

    CPU1 Flow:

    EALLOW;
    
    CpuSysRegs.PCLKCR0.bit.GTBCLKSYNC = 0;
    
    // Configure PWMs for CPU1
    
    while (IpcRegs.IPCSTS.bit.IPC17 == 0);  // Wait for CPU2 to configure PWMs
    IpcRegs.IPCACK.bit.IPC17 = 1;               // Acknowledge message from CPU2
    
    CpuSysRegs.PCLKCR0.bit.GTBCLKSYNC = 1;   // Set GTBCLKSYNC = 1 to start time base counter for all EPWMs
    
    EDIS;

    CPU2 Flow:

    EALLOW;
    
    // Configure PWMs for CPU2
    
    IpcRegs.IPCSET.bit.IPC17    = 1; // Let CPU1 know EPWMs have been configured
    
    EDIS;

    You'll need to include "F2837xD_Ipc_drivers.h" if you do not have this within your project. 

    I would recommend taking a look at this IPC example too:

    C:\ti\c2000\C2000Ware_version\device_support\f2837xd\examples\dual\ipc_gpio_toggle

    Best Regards,

    Marlyn

  • What Marlyn has mentioned above is exactly correct.

    The GLOBAL TBCLKSYNC is disabled by CPU1, the EPWMs on CPU1 are intiialized. Meanwhile CPU2 configures the EPWMs on CPU2. CPU1 waits for CPU2 to finish (the IPC code). Once all intiialization is comepleted. CPU1 enables all ePWMs at the same time, by enabling the global clock sync.

    Nima