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:CPU 计时器中断赢得't Trigger

Guru**** 2535750 points
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1551514/tms320f2800137-cpu-timer-interrupt-won-t-trigger

器件型号:TMS320F2800137
Thread 中讨论的其他器件:SysConfigC2000WARE

工具/软件:

您好 TI、

我尝试让一个 CPU 计时器为 Modbus 库工作。 我下面是 timer_ex1_cputimer_sysconfig 示例。

CPU 计时器在 main() 中进行测试、

void main(void)
{
    //Vars
    //Modbus
    eMBErrorCode eStatus;
    
    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull-ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Disable sync(Freeze clock to PWM as well). GTBCLKSYNC is applicable
    // only for multiple core devices. Uncomment the below statement if
    // applicable.
    //
    // SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_GTBCLKSYNC);
    //SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    //
    // PinMux and Peripheral Initialization
    //
    Board_init();

    //
    // Enable sync and clock to PWM
    //
    //SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    //
    // C2000Ware Library initialization
    //
    C2000Ware_libraries_init();

    //
    // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
    //
    EINT;
    ERTM;
    
    xMBPortTimersInit( 20 );
    vMBPortTimersEnable( );
    while(1)
    {
        
    }
}

xMBPortTimersInit( 20 );
配置 CPU 计时器、
BOOL
xMBPortTimersInit( USHORT usTim1Timerout50us )
{
    EALLOW;

    CPUTimer_setEmulationMode(myCPUTIMER0_BASE, CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
	CPUTimer_setPreScaler(myCPUTIMER0_BASE, 0U);
    //Set the period for the MB Library.
	CPUTimer_setPeriod(myCPUTIMER0_BASE, 120U);

	CPUTimer_enableInterrupt(myCPUTIMER0_BASE);
	CPUTimer_stopTimer(myCPUTIMER0_BASE);

	CPUTimer_reloadTimerCounter(myCPUTIMER0_BASE);

    Interrupt_register(myCPUTIMER0_BASE, &prvvTIMERExpiredISR);
	Interrupt_enable(myCPUTIMER0_BASE);
	
    EDIS;

    return TRUE;
}
vMBPortTimersEnable();
启用计时器、
inline void
vMBPortTimersEnable(  )
{
    EALLOW;
    CPUTimer_startTimer(myCPUTIMER0_BASE);
    EDIS;
}
从不调用中断、
inline void
vMBPortTimersDisable(  )
{
    EALLOW;
    CPUTimer_stopTimer(myCPUTIMER0_BASE);
    EDIS;
}
我似乎无法弄清楚为什么从未调用中断。 我已经把一个断点在那里和执行永不停止。
您是否对如何进一步调试该问题有任何建议?
谢谢、
Allan
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    让我看看这个、然后回到您那里。

    此致、

    Delaney

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

    您好:

    您能否在 CCS 寄存器视图中检查并验证 CPU 计时器中断的 IER 和 PIEIER 标志是否已启用? 并且 INTM 位被清除?

    此致、

    Delaney

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

    尊敬的 Delaney:

    ==================================================================

    MODBUS 实现方式

    ==================================================================

    我检查了 CPUTimer0 的 IER 和 PIEIER 标志。

    IER 寄存器全部为零并且从不变化。 即使在调用 BOOL xMBPortTimersInit() 之后。  

    所有其他 PIEIERx 寄存器为零。

    INTM 位被清除。

    =======================================

    timer_cputimer_example_sysconfig

    =======================================

    运行示例代码确实会更改 INT1、

    运行示例代码也会更改 PIEIER1 -> INTx7。

    INTM 清除并保持清除。

    谢谢、

    Allan

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

    您好:  

    Delaney  目前已离职  下周初她回来时会回到您身边。  感谢您的耐心。

    此致、

    Aishwarya

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

    嗨、Allan、

    很抱歉耽误你的时间。 我还应该提到的一个问题是、您能否验证在检查寄存器值时是否在 CCS 窗口中打开了“Continuous Refresh“? 这将确保它们始终得到正确更新。

    如果第一个值与第一个屏幕截图相同(即使已打开连续刷新)、则 PIEIER 和 IER 将是问题所在。 为了使中断传播到 CPU、INT 的 PIEIER 需要为 1(已启用)、组的 PIEACK 需要为 0(已启用)、组的 IER 需要为 1(已启用)、全局 INTM 需要为 0(已启用)。

    此致、

    Delaney

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

    尊敬的 Delaney:

    是、我确信在两组寄存器值期间都启用了自动刷新。

    谢谢、

    Allan

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

    嗨、Allan、

    我明天会再回复您。

    此致、

    Delaney  

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

    嗨、Allan、

    感谢您的澄清。 听起来问题似乎出在 MODBUS 库、因为该软件层中的配置没有正确启用中断。 TI 是否提供该库(如果是,您是否可以在 C2000ware 中提供路径)?

    此致、

    Delaney

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

    尊敬的 Delaney:

    我正在使用的 Modbus 库是一个名为 FreeModBus 的开源库。 它不由 TI 提供。  

    我能够通过创建一个不使用 SYSCFG 工具的新项目来解决中断处理程序未被调用的问题。

    由于不使用 SYSCFG 工具、我必须手动配置计时器的所有设置、

    将 xMBPoirtTImersInit 更改为

    BOOL xMBPortTimersInit( USHORT usTim1Timerout50us )
    {
        EALLOW;
        Interrupt_register(INT_TIMER0, &prvvTIMERExpiredISR);
        initCPUTimer0();
    
        uint32_t count = 50U*usTim1Timerout50us;
        
        configCPUTimer0(DEVICE_SYSCLK_FREQ, count);
    
        CPUTimer_enableInterrupt(CPUTIMER0_BASE);
        Interrupt_enable(INT_TIMER0);
        CPUTimer_startTimer(CPUTIMER0_BASE);
        EDIS;
        return TRUE;
    }

    vMBPortTimersEnable()

    inline void
    vMBPortTimersEnable(  )
    {
        EALLOW;
        CPUTimer_startTimer(CPUTIMER0_BASE);
        EDIS;
    }

    vMBPortTimersDisable( )
    inline void
    vMBPortTimersDisable(  )
    {
        EALLOW;
        CPUTimer_stopTimer(CPUTIMER0_BASE);
        EDIS;
    }
    
    __ interrupt void prvTIMERExpiredISR( void )
    __interrupt void prvvTIMERExpiredISR( void )
    {
        // Acknowledge this interrupt to receive more interrupts from group 1
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
        //ModBus functionc all to notify the protocol stack that the timer has expired.
        ( void )pxMBPortCBTimerExpired(  );
    }
    
    计时器配置为直接调用 driverlib。
    void initCPUTimer0()
    {
        //0. Initialize timer period to maximum
        CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
    
        //1. Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
        CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
    
        //2 Make sure timer is stopped
        CPUTimer_stopTimer(CPUTIMER0_BASE);
    
        //3. Reload all counter register with period value
        CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
    }
    void configCPUTimer0(float freq, float period)
    {
        uint32_t temp;
        uint32_t cpuTimer = CPUTIMER0_BASE;
        //
        // Initialize timer period:
        //
        temp = (uint32_t)((freq / 1000000) * period);
        CPUTimer_setPeriod(cpuTimer, temp - 1);
    
        //
        // Set pre-scale counter to divide by 1 (SYSCLKOUT):
        //
        CPUTimer_setPreScaler(cpuTimer, 0);
    
        //
        // Initializes timer control register. The timer is stopped, reloaded,
        // free run disabled, and interrupt enabled.
        // Additionally, the free and soft bits are set
        //
        CPUTimer_stopTimer(cpuTimer);
        CPUTimer_reloadTimerCounter(cpuTimer);
        CPUTimer_setEmulationMode(cpuTimer,
                                  CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
        CPUTimer_enableInterrupt(cpuTimer);
    }