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.

[参考译文] TMS320F28375S:定时器频率除以2

Guru**** 2384710 points
Other Parts Discussed in Thread: TMS320F28375S, C2000WARE
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/993308/tms320f28375s-timer-frequency-divide-by-two

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

您好!

   使用 TMS320F28375S,可将定时器频率除以2。 下面是我的计时器配置

void IntCPUTimer(void)
{



    Interrupt_register(INT_TIMER0, &cpuTimer0ISR);
    Interrupt_register(INT_TIMER1, &cpuTimer1ISR);

        //
        // Initializes the Device Peripheral. For this example, only initialize the
        // Cpu Timers.
        //
        initCPUTimers();

        //
        // Configure CPU-Timer 0, 1, and 2 to interrupt every second:
        // 1 second Period (in uSeconds)
        //
        configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ,  1000000);
        configCPUTimer1(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 1000000);
        //
        // 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, the below settings must also
        // be updated.
        //
        CPUTimer_enableInterrupt(CPUTIMER0_BASE);
        CPUTimer_enableInterrupt(CPUTIMER1_BASE);
        //
        // Enables CPU int1, int13, and int14 which are connected to CPU-Timer 0,
        // CPU-Timer 1, and CPU-Timer 2 respectively.
        // Enable TINT0 in the PIE: Group 1 interrupt 7
        //
        Interrupt_enable(INT_TIMER0);
         Interrupt_enable(INT_TIMER1);
        //
        // Starts CPU-Timer 0, CPU-Timer 1, and CPU-Timer 2.
        //
        CPUTimer_startTimer(CPUTIMER0_BASE);
        CPUTimer_startTimer(CPUTIMER1_BASE);

    }


//
// initCPUTimers - This function initializes all three CPU timers
// to a known state.
//
void initCPUTimers(void)
{
    //
    // Initialize timer period to maximum
    //
    CPUTimer_setPeriod(CPUTIMER0_BASE, 0xFFFFFFFF);
    CPUTimer_setPeriod(CPUTIMER1_BASE, 0xFFFFFFFF);
    //
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
    //
    CPUTimer_setPreScaler(CPUTIMER0_BASE, 0);
    CPUTimer_setPreScaler(CPUTIMER1_BASE, 0);
    //
    // Make sure timer is stopped
    //
    CPUTimer_stopTimer(CPUTIMER0_BASE);
    CPUTimer_stopTimer(CPUTIMER1_BASE);
    //
    // Reload all counter register with period value
    //
    CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
    CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
    //
    // Reset interrupt counter
    //



}

void configCPUTimer(uint32_t cpuTimer, float freq, float period)
{
        CPUTimer_setPeriod(cpuTimer, 20);   // For 1ms sec set value as 2000

         //
         // Set pre-scale counter to divide by 1 (SYSCLKOUT):
         //
         CPUTimer_setPreScaler(cpuTimer, 9999);

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

器件频率设置 为

谢谢、此致、

Rani

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

    您好 Rani、

    您使用的是定制板还是 controlCARD? 只需验证您使用的 是20MHz XTAL。

     您可以在调用 configCPUTimer()函数时更改计时器的周期,方法是传递不同的值而不是更改函数内的代码。 如果您运行 timer_ex1_cputimers 项目(C:\ti\c2000Ware_version\driverlib\f2837xd\examples\cpu1\timer)而不对其进行修改、您会获得正确的结果吗?

    此致、

    Marlyn

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

    您好、

    是定制板...

    只需验证您使用的 是20MHz XTAL。

    是的。。。 20MHz XTAL.

     您可以在调用 configCPUTimer()函数时更改计时器的周期,方法是传递不同的值而不是更改函数内的代码。 如果您运行 timer_ex1_cputimers 项目(C:\ti\c2000Ware_version\driverlib\f2837xd\examples\cpu1\timer)而不对其进行修改、您会获得正确的结果吗?

    我们在试用后回来。
    感谢您的指导,直到我解决问题。

    Rgds

    Rani