- TMS320C6748™ 定点和浮点DSP中文说明 6.30 Timers:

寄存器类型 | 描述 |
---|
Timer Counter Register 12 | 记录定时器当前计数值。这个值会随时间自动增加或减少(取决于定时器配置),用于跟踪定时器经过的时间。 |
Timer Period Register 12 | 设置定时器周期值。当定时器计数达到此值时,会发生溢出事件(如中断)。通常用于定义定时器的一个完整周期。 |
Timer Control Register | 控制定时器的行为,包括但不限于启动/停止定时器、选择计数模式(递增/递减)、是否启用中断等。 |
Timer Global Control Register | 控制多个定时器或者整个定时器模块的工作状态,比如可以用来同时启动或停止所有定时器,设置定时器的全局工作模式等。 |
Watchdog Timer Control Register | 控制看门狗定时器的行为,例如设置看门狗定时器的使能与禁用、复位条件、超时周期等,用于系统监控和恢复。 |
Timer Reload Register 12 | 设定定时器重载值。当定时器溢出或被手动触发时,定时器计数器会被重置为此值,以便重新开始计数。 |
Timer Capture Register 12 | 捕捉定时器计数值。在特定事件(如外部信号边沿触发)发生时,定时器当前计数值会被复制到此寄存器中以供读取。 |
Timer Interrupt Control and Status Register | 控制定时器中断的使能及显示中断状态。它可能包含各个定时器中断的使能位以及标志定时器事件发生的标志位。 |
Compare Register 0 | 设置比较值。定时器计数值与该寄存器中的值进行比较,当二者相等时,可以触发特定动作,如产生中断或输出信号变化。 |
中断示例
USTIMER_init();
//-----------------------------------------------------------------------------
// \brief initialize the microsecond timer.
// https://bbs.eeworld.com.cn/thread-297763-1-1.html
//
// \param none.
//
// \return uint32_t
// ERR_NO_ERROR - everything is ok...us timer ready to use.
// ERR_INIT_FAIL - something happened during initialization.
//-----------------------------------------------------------------------------
uint32_t USTIMER_init(void)
{
// configure timer 0 for free run.
// 32-bit unchained mode, timer3:4 /12 prescaler.
// enable muxed pins as gpio outputs and disable all related interrupts.
// would need to also setup the pinmux register to select the gpio
// function of these pins in order to use as gpio.
TMR0->GPINT_GPEN = GPENO12 | GPENI12;
TMR0->GPDATA_GPDIR = GPDIRO12 | GPDIRI12;
// stop and reset timer.
TMR0->TGCR = 0x00000000;
TMR0->TCR = 0x00000000;
// disable interrupts and set emulation to free run.
TMR0->INTCTLSTAT = 0;
SETBIT(TMR0->EMUMGT, SOFT | FREE);
// config timer0 in 32-bit unchained mode.
// remove timer0 - 3:4 from reset.
SETBIT(TMR0->TGCR, PRESCALER(TIMER_DIV - 1) | TIMMODE_32BIT_UNCHAINED | TIM34RS );
// init timer0 - 1:2 period....use full range of counter.
TMR0->TIM34 = 0x00000000;
TMR0->PRD34 = 0x00000000;
// start timer0 - 3:4.
SETBIT(TMR0->TCR, ENAMODE34_CONT);
return (ERR_NO_ERROR);
}
StartTimer重新配置定时器
void StartTimer(unsigned short Time)
{
CLRBIT(TMR1->TGCR, TIM34RS);// stop the timer
TMR1->TCR = 0x00000000;
SETBIT(TMR1->INTCTLSTAT, PRDINTSTAT34);
TMR1->TIM34 = 0x00000000;
TMR1->PRD34 = Time; // 设置周期值
SETBIT(TMR1->TCR, ENAMODE34_CONT);
SETBIT(TMR1->TGCR, TIM34RS);
}
进行中断
// 中断判断
if( (TMR1->INTCTLSTAT) & (1<<17) ){
}
- https://www.ti.com/lit/ug/spruh79c/spruh79c.pdf:
