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.

TMS320F2800137: ePWM coming out when running code from RAM but not from Flash

Part Number: TMS320F2800137
Other Parts Discussed in Thread: SYSCONFIG

I have a F2800137 C2000 microcontroller and I am trying to generate four sets of complementary ePWM signals, for a total of eight signals. I am using Sysconfig to configure these ePWMs. For some reason, when I run my program from flash, one and sometimes two ePWM signals (not complementary -- usually it's only one of the signals in a complementary pair) doesn't come out. But, when I run it from RAM, all of the PWMs come out.

I thought originally that somehow the deadband module wasn't setting some registers correctly, but since I am choosing both the outputs to be based off of the same ePWM signal, I don't see how one of the ePWMs in the complementary pair can come out, but not the other.

I also thought it might be because I have an ADC ISR to read values from an ADC which triggers every 5 cycles, and that it might be taking too long. But I commented out the entire ISR, and it still gives this behavior.

My ePWMs have a frequency of 100 kHz. I've screenshotted some relevant Sysconfig settings and code below:

image.png

image.png

image.png

image.png

void main(void)
{
    // *********************** Initialization (from example) ********************** //
    Device_init();                     // Initialize device clock and peripherals
    Device_initGPIO();                  // Disable pin locks and enable internal pull-ups.
    Interrupt_initModule();             // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    Interrupt_initVectorTable();        // Initialize the PIE vector table with pointers to the shell ISRs

    Board_init();                       // Configure peripherals (from SysConfig)

    // Disable and re-enable sync and EPWM clock (don't ask why, it's from the example)
    SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    // Configure the CPU Timer
    configCPUTimer(TIMER_BASE, DEVICE_SYSCLK_FREQ, 1000000);

    // Enable global Interrupts and higher priority real-time debug events:
    EINT;  // Enable Global interrupt INTM
    ERTM;  // Enable Global realtime interrupt DBGM

    CPUTimer_startTimer(TIMER_BASE);    // start CPU 0 timer

    // set 50% duties for testing
    set_duty(PJX_BUCK_BASE, 605);
    set_duty(PJX_BOOST_BASE, 605);
    set_duty(MJX_BUCK_BASE, 605);
    set_duty(MJX_BOOST_BASE, 605);

    use_control = 0;

    // Enter main control loop (does nothing for now)
    while (1) {
        ;
    }
}

 

void set_duty(uint32_t epwm_module, volatile uint16_t desired_duty)
{
    // invert +jx buck and +jx boost
    if (epwm_module == PJX_BUCK_BASE || epwm_module == PJX_BOOST_BASE) {
        desired_duty = (uint16_t) EPWM_TBPRD - desired_duty;
    }

    // set EPWM A counter compare value
    EPWM_setCounterCompareValue(epwm_module, EPWM_COUNTER_COMPARE_A, desired_duty);

    // set to low at zero, high at counter compare
    EPWM_setActionQualifierAction(epwm_module, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
    EPWM_setActionQualifierAction(epwm_module, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(epwm_module, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
}

I am programming my C2000 using JTAG, and I have the boot pins GPIO24 and GPIO37 pulled high through 3.3k pullup resistors, so it should be running from flash on startup. 

Thanks in advance for your input!

 

 

  • Hi Ben,

    Can you cross check if the DBCTL register is set correctly while the code is running. You can do that in debug mode by viewing the register window. Can you also share the screenshot of DBCTL register value while running the code from RAM and FLASH.

    It is also a good idea to compare the initialization register for both the cases to narrow down the issue.

    Regards,
    Harisyam