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.

LAUNCHXL-F28379D: EPWM and ADC on CPU2

Part Number: LAUNCHXL-F28379D

Hi,

I have EPWM and ADC working on CPU1. Now I want to move these two modules to CPU2.

I did the below changes but I cant get output on Pin 40-37, even though CMPA registers of both EPWM 1 and 2 getting updated can be seen in the Expressions window.

1. Moved ownership of EPWM and ADC modules to CPU2

Fullscreen
1
2
3
4
5
6
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL0_EPWM, 1, SYSCTL_CPUSEL_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL0_EPWM, 2, SYSCTL_CPUSEL_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL11_ADC, 1, SYSCTL_CPUSEL_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL11_ADC, 2, SYSCTL_CPUSEL_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL11_ADC, 3, SYSCTL_CPUSEL_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL11_ADC, 4, SYSCTL_CPUSEL_CPU2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

2. Assigned CPU2 as the master of GPIO pins of EPWM

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
GPIO_setPinConfig(SYNCH_PWM_OP_1A_CONFIG);
GPIO_setDirectionMode(SYNCH_PWM_OP_1A, GPIO_DIR_MODE_OUT);
GPIO_setMasterCore(SYNCH_PWM_OP_1A, GPIO_CORE_CPU2);
GPIO_setPinConfig(SYNCH_PWM_OP_1B_CONFIG);
GPIO_setDirectionMode(SYNCH_PWM_OP_1B, GPIO_DIR_MODE_OUT);
GPIO_setMasterCore(SYNCH_PWM_OP_1B, GPIO_CORE_CPU2);
GPIO_setPinConfig(SYNCH_PWM_OP_2A_CONFIG);
GPIO_setDirectionMode(SYNCH_PWM_OP_2A, GPIO_DIR_MODE_OUT);
GPIO_setMasterCore(SYNCH_PWM_OP_2A, GPIO_CORE_CPU2);
GPIO_setPinConfig(SYNCH_PWM_OP_2B_CONFIG);
GPIO_setDirectionMode(SYNCH_PWM_OP_2B, GPIO_DIR_MODE_OUT);
GPIO_setMasterCore(SYNCH_PWM_OP_2B, GPIO_CORE_CPU2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

3. Assigned ownership of GSRAM 8, 9, 10 to CPU2 and only those are using in CPU2 linker file.

Fullscreen
1
2
3
MemCfg_setGSRAMMasterSel(MEMCFG_SECT_GS8, MEMCFG_GSRAMMASTER_CPU2);
MemCfg_setGSRAMMasterSel(MEMCFG_SECT_GS9, MEMCFG_GSRAMMASTER_CPU2);
MemCfg_setGSRAMMasterSel(MEMCFG_SECT_GS10, MEMCFG_GSRAMMASTER_CPU2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Are there any additional settings that need to be done in CPU2/CPU1 for enabling output to the GPIO pins?

Regards,

Rashmitha

  • Rashmitha,

    Can you clarify which GPIOs you are trying to configure? GPIO37-GPIO40 don't have any PWM functions muxed with them, and I'm not familiar with the mux'd function SYNCH_PWM_OP_1A_CONFIG, etc.

    If you are setting a mux function of the GPIO, you should not need to set the direction; the mux selection will take care of that aspect for you.  This is only needed if the GPIO is used as a pure GPIO to tell the device if it will be input/output.  It doesn't hurt to call this, but it shouldn't be needed.

    Best,

    Matthew

  • Hi Matthew, 

    Thanks for your reply. I had the GPIO initializations in a function but was not calling them. I can now get the output on the pins 37-40

    Now, the EPWM code I have was generating a particular frequency on CPU1, EPWM1 ISR triggered at 180kHz. 

    This same identical code when moved to CPU2 is not giving the same frequency output as CPU1, on CPU2 I see that EPWM1 ISR is triggered at 120kHz.

    And the processing inside the EPWM ISR on CPU1 takes 350ns, same on CPU2 takes 4us.

    I understand from a lot of other posts on the forum that CPU1 and CPU2 use the same clock.

    I have also ensured that both of them are running from FLASH.

    What else could be slowing down CPU2?

    Regards,

    Rashmitha

  • Are there any shared resources that CPU1 and CPU2 may be accessing at the same time(other than ADC Result Regs).  There may be some stall/arbitration that is occurring that is slowing CPU2 down. 

    I'm assuming that no nesting is being done inside the ePWM ISR as well.

    Best,

    Matthew

  • There are no shared resources that I am aware of other than IPC for passing a flag.

    The reason for introducing CPU2 is to isolate ADC and EPWM from CPU1. 

    There is no nesting in EPWM1 ISR, it only has 2 lines to update CMPA registers. The CMPA values are picked up from a 100x10 const array stored on FLASH.

    Another problem that I have is, I would like to turn ON and turn OFF the EPWM module through an external input. For this I am setting and clearing the clock bits as below

    CpuSysRegs.PCLKCR2.bit.EPWM1 = 0;
    CpuSysRegs.PCLKCR2.bit.EPWM2 = 0;

    Now, after initializing the module I turn OFF the clock. Then when I get an external signal through a GPIO I enable the clock to start PWM generation. Similarly, I clear the clock bits to turn OFF the PWM generation. What is happening here is that, the very first time I turn ON PWM generation, it works and I get output on the pins but once I turn OFF and then try to turn back on the 2nd time; I see that the clock bits are set but the EPWM ISR is no longer getting hit and there is no output at all.

    Regards,

    Rashmitha

  • Rashmitha,

    You will want to use the local ePWM register controls to start/stop the PWM output.  Disabling the clocks to the module is likely causing some undefined conditions in the module resulting in it needing to be re-initialized to re-start the output.

    I'm going to ask a PWM expert be assigned to the thread to help more in this aspect.  At a high level you will want to use the GPIO to drive a Trip Zone event to stop the PWM and then SW to re-start it.  They can help with the undetermined increase in ISR time as well.

    Best,

    Matthew

  • Hi Rashmitha, 

    Disabling the clocks to the modules could be causing undefined behaviors like Matt said. Instead of turning off and on by writing to those clock registers. You could use the trip zone module to set the outputs of epwm outputs to low based on that external signal. This will require using the input xbar and configuring a few things within the trip zone module. You will be using the one shot trip event.

    If you have questions on this there are plenty of resources to learn about setting it up. If you have any specific epwm questions you should create a separate thread and I will help you on that new thread.

    I have also attached an app guides that could help as reference to set up this.

    1. C2000 ePWM Developer’s Guide: www.ti.com/.../sprad12.pdf

    Here is also our online training academy that is also super helpful

    1. C2000 Academy: dev.ti.com/.../node