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:从内核(CPU2)的 CPU 定时器0未被处理

Guru**** 2609955 points
Other Parts Discussed in Thread: C2000WARE

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1059228/tms320f28379d-cpu-timer-0-for-slave-core-cpu2-not-getting-serviced

器件型号:TMS320F28379D
主题中讨论的其他器件:C2000WARE

我使用相同 的源代码来初始化两个内核(CPU1和 CPU2)的 TIMER0。 我能够初始化、启动和处理 CPU1 (主内核)的 TIMER0中断、但对于 CPU2 (从内核)、我看到在 TIMER0启动并启用全局中断后、它始终会按 TIMER0的 ISR。  我不知道为什么使用相同的逻辑针对不同的内核观察到这种不同的行为?

我清楚地说明了以下几点:
每个内核都有其 定时器实例(TIMER0、Timer1和 TIMER2)
TIMER2专用于 TI-RTOS (如果使用)、可在非 RTOS 应用中用作普通定时器模块。
3.  CPU 内核之间对于它们各自的定时器模块没有相互依赖关系。

Device Interrupt Architecture (source TRM for TMS320F28379D (spruhm8i) by Texas Instruments)



有人能帮我找出 CPU2的 TIMER0可能出现的问题吗?

此致。

Sumit Panse

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

    您好、Sumit、

    [引用 userid="502559" URL"~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/C2000-microcontrollers-forume/1059228/tms320f28379d-cpu-timer-0-for-slave-core-cpu2-not getting-service 命令"]我看到它始终启动 TIMER0[并启用了全局报价函数0中断]

    您能提供更多背景信息吗? 主题行指出 CPU2上的计时器0不被处理、但您在这里表示为 TIMER0输入 ISR。 是否在您启动计时器后而不是在计时器计数完成后调用 ISR?

    此致、

    Marlyn

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

    您好、Marlyn、

    抱歉、我的主题行不正确。 是的、您答对了、ISR 会在计时器启动后立即调用。

    此致、

    Sumit Panse

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

    您好、Sumit、

    感谢您的澄清! 您是否使用 driverlib 或位字段代码?

    我修改了 C2000Ware 中的'IPC_ex1_GPIO_toggle'示例、以便在 CPU1/CPU2中同时启动 timer0。 每次计时器完成时应发生中断:C:\ti\c2000\C2000Ware_4_00_00\device_support\f2837xd\examples\dual\ipc_gpio_toggle

    如果您使用的是位域、请尝试此操作吗? 如果不是、请告诉我、我可以在 driverlib 中生成一些内容。

    CPU1:

    //
    // Included Files
    //
    #include "F28x_Project.h"
    #include "F2837xD_Ipc_drivers.h"
    
    __interrupt void cpu_timer0_isr(void);
    //
    // Main
    //
    void main(void)
    {
    //
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    //
        InitSysCtrl();
    
    #ifdef _STANDALONE
    #ifdef _FLASH
        //
        // Send boot command to allow the CPU2 application to begin execution
        //
        IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
    #else
        //
        // Send boot command to allow the CPU2 application to begin execution
        //
        IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
    #endif
    #endif
    
    //
    // Clear all __interrupts and initialize PIE vector table:
    //
       DINT;
    
    //
    // Initialize the PIE control registers to their default state.
    // The default state is all PIE __interrupts disabled and flags
    // are cleared.
    // This function is found in the F2837xD_PieCtrl.c file.
    //
       InitPieCtrl();
    
    //
    // Disable CPU __interrupts and clear all CPU __interrupt flags:
    //
       IER = 0x0000;
       IFR = 0x0000;
    
    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the __interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F2837xD_DefaultIsr.c.
    // This function is found in F2837xD_PieVect.c.
    //
       InitPieVectTable();
    
    //
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
    //
       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.TIMER0_INT = &cpu_timer0_isr;
       EDIS;    // This is needed to disable write to EALLOW protected registers
    
    //
    // Initialize the Device Peripheral. This function can be
    //         found in F2837xD_CpuTimers.c
    //
       InitCpuTimers();   // For this example, only initialize the Cpu Timers
    
    //
    // Configure CPU-Timer 0 to __interrupt every 500 milliseconds:
    // 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
    //
       ConfigCpuTimer(&CpuTimer0, 60, 500000);
    
    //
    // To ensure precise timing, use write-only instructions to write to the entire
    // register. Therefore, if any of the configuration bits are changed in
    // ConfigCpuTimer and InitCpuTimers (in F2837xD_cputimervars.h), the below
    // settings must also be updated.
    //
       //CpuTimer0Regs.TCR.all = 0x4001;
    
    //
    // Enable CPU INT1 which is connected to CPU-Timer 0:
    //
       IER |= M_INT1;
    
    //
    // Enable TINT0 in the PIE: Group 1 __interrupt 7
    //
       PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    
    //
    // Enable global Interrupts and higher priority real-time debug events:
    //
       EINT;   // Enable Global __interrupt INTM
       ERTM;   // Enable Global realtime __interrupt DBGM
    
       while (IpcRegs.IPCSTS.bit.IPC17 == 0);
       IpcRegs.IPCACK.bit.IPC17 = 1;
       CpuTimer0Regs.TCR.bit.TSS   = 0;
    
    //
    // Step 6. IDLE loop. Just sit and loop forever (optional):
    //
       for(;;);
    }
    
    //
    // cpu_timer0_isr - CPU Timer0 ISR that toggles GPIO32 once per 500ms
    //
    __interrupt void cpu_timer0_isr(void)
    {
       CpuTimer0.InterruptCount++;
    
       //
       // Acknowledge this __interrupt to receive more __interrupts from group 1
       //
       PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    //
    // End of file
    //

    CPU2:

    //
    // Included Files
    //
    #include "F28x_Project.h"
    #include "F2837xD_Ipc_drivers.h"
    
    __interrupt void cpu_timer0_isr(void);
    
    //
    // Main
    //
    void main(void)
    {
    //
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    //
       // InitSysCtrl();
    
    
        //
        // Clear all __interrupts and initialize PIE vector table:
        //
           DINT;
    
        //
        // Initialize the PIE control registers to their default state.
        // The default state is all PIE __interrupts disabled and flags
        // are cleared.
        // This function is found in the F2837xD_PieCtrl.c file.
        //
           InitPieCtrl();
    
        //
        // Disable CPU __interrupts and clear all CPU __interrupt flags:
        //
           IER = 0x0000;
           IFR = 0x0000;
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        // This will populate the entire table, even if the __interrupt
        // is not used in this example.  This is useful for debug purposes.
        // The shell ISR routines are found in F2837xD_DefaultIsr.c.
        // This function is found in F2837xD_PieVect.c.
        //
           InitPieVectTable();
    
        //
        // Interrupts that are used in this example are re-mapped to
        // ISR functions found within this file.
        //
           EALLOW;  // This is needed to write to EALLOW protected registers
           PieVectTable.TIMER0_INT = &cpu_timer0_isr;
           EDIS;    // This is needed to disable write to EALLOW protected registers
    
        //
        // Initialize the Device Peripheral. This function can be
        //         found in F2837xD_CpuTimers.c
        //
           InitCpuTimers();   // For this example, only initialize the Cpu Timers
    
        //
        // Configure CPU-Timer 0 to __interrupt every 500 milliseconds:
        // 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
        //
           ConfigCpuTimer(&CpuTimer0, 60, 500000);
    
        //
        // To ensure precise timing, use write-only instructions to write to the entire
        // register. Therefore, if any of the configuration bits are changed in
        // ConfigCpuTimer and InitCpuTimers (in F2837xD_cputimervars.h), the below
        // settings must also be updated.
        //
           //CpuTimer0Regs.TCR.all = 0x4001;
    
        //
        // Enable CPU INT1 which is connected to CPU-Timer 0:
        //
           IER |= M_INT1;
    
        //
        // Enable TINT0 in the PIE: Group 1 __interrupt 7
        //
           PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    
        //
        // Enable global Interrupts and higher priority real-time debug events:
        //
           EINT;   // Enable Global __interrupt INTM
           ERTM;   // Enable Global realtime __interrupt DBGM
    
        IpcRegs.IPCSET.bit.IPC17    = 1;
        CpuTimer0Regs.TCR.bit.TSS   = 0;
        //
        // Step 6. IDLE loop. Just sit and loop forever (optional):
        //
           for(;;);
        }
    
        //
        // cpu_timer0_isr - CPU Timer0 ISR that toggles GPIO32 once per 500ms
        //
        __interrupt void cpu_timer0_isr(void)
        {
           CpuTimer0.InterruptCount++;
    
           //
           // Acknowledge this __interrupt to receive more __interrupts from group 1
           //
           PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
        }
    

    此致、

    Marlyn