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:从 RAM 而不是从闪存运行代码时 EPWM 输出

Guru**** 2901170 points

Other Parts Discussed in Thread: SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1647445/tms320f2800137-epwm-coming-out-when-running-code-from-ram-but-not-from-flash

器件型号: TMS320F2800137
主题: SysConfig 中讨论的其他器件

我使用的是 F2800137 C2000 微控制器、我正在尝试生成四组互补 ePWM 信号、总共需要八个信号。 我使用 SysConfig 配置这些 ePWM。 出于某种原因、当我从闪存运行程序时、一个有时两个 EPWM 信号(不是互补信号,通常只是互补信号对中的一个信号)不会发出。 但是、当我从 RAM 运行时、所有 PWM 都会出来。

我最初认为死区模块没有正确设置一些寄存器、但由于我正在选择两个输出来基于同一个 ePWM 信号、我看不到互补对中的一个 ePWM 可以如何产生、但另一个 ePWM 无法产生。

我还认为这可能是因为我有一个 ADC ISR 从每 5 个周期触发一次的 ADC 读取值、这可能需要很长时间。 但我注释掉了整个 ISR、但仍然给出了这种行为。

我的 ePWM 频率为 100kHz。 我筛选了以下一些相关的 SysConfig 设置和代码:

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);
}

我正在使用 JTAG 对 C2000 进行编程、并将引导引脚 GPIO24 和 GPIO37 通过 3.3k 上拉电阻拉至高电平、因此它应该在启动时从闪存运行。  

提前感谢您的意见!

 

 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Ben、

    您是否可以在代码运行时交叉检查 DBCTL 寄存器是否设置正确。 您可以在调试模式下通过查看寄存器窗口来执行该操作。 您是否还可以 在从 RAM 和闪存运行代码时共享 DBCTL 寄存器值的屏幕截图。

    也可以比较 这两种情况的初始化寄存器以缩小问题范围。

    此致、
    Harisyam