主题中讨论的其他器件: 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