C6748基于starterware的64位定时器。仿照starterware中的例程timer。试了低32位有效,高32为无效,请问对应的寄存器该怎么配置
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.
C6748基于starterware的64位定时器。仿照starterware中的例程timer。试了低32位有效,高32为无效,请问对应的寄存器该怎么配置
这不是配置成的64bit吗?怎么个没用啊?
timerCounter.c:
int main(void)
{
/* Set up the UART2 peripheral */
UARTStdioInit();
/* Set up the Timer2 peripheral */
TimerSetUp64Bit();
/* Set up the AINTC to generate Timer2 interrupts */
TimerIntrSetUp();
/* Enable the timer interrupt */
TimerIntEnable(SOC_TMR_2_REGS, TMR_INT_TMR12_NON_CAPT_MODE);
#ifndef _TMS320C6X
/* Switch to non privileged mode; This is done for demonstration purpose */
CPUSwitchToUserMode();
#endif
/* Send the first String */
UARTPuts("\r\nTencounter: 0", -1);
/* Start the timer. Characters from cntArr will be sent from the ISR */
TimerEnable(SOC_TMR_2_REGS, TMR_TIMER12, TMR_ENABLE_CONT);
** Setup the timer for 64 bit mode
*/
static void TimerSetUp64Bit(void)
{
/* Configuration of Timer */
TimerConfigure(SOC_TMR_2_REGS, TMR_CFG_64BIT_CLK_INT);
*(unsigned int *)(SOC_TMR_2_REGS + 0x4) |=1; //add to enable JTAG debug.
/* Set the 64 bit timer period */
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER12, TMR_PERIOD_LSB32);
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER34, TMR_PERIOD_MSB32);
}
// 64位 定时器 / 计数器周期
// 定时时间 1 秒
// 低32位
#define TMR_PERIOD_LSB32 (0x0D970100)
// 高32位 0
#define TMR_PERIOD_MSB32 (0x3)
/****************************************************************************/
/* */
/* 定时器 / 计数器初始化 */
/* */
/****************************************************************************/
void TimerInit(void)
{
// 配置 定时器 / 计数器 2 为 64 位模式
TimerConfigure(SOC_TMR_2_REGS, TMR_CFG_64BIT_CLK_INT);
// 设置周期
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER12, TMR_PERIOD_LSB32);
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER34, TMR_PERIOD_MSB32);
// 使能 定时器 / 计数器 2
TimerEnable(SOC_TMR_2_REGS, TMR_TIMER_BOTH, TMR_ENABLE_CONT);
}
/****************************************************************************/
/* */
/* 定时器 / 计数器中断初始化 */
/* */
/****************************************************************************/
void TimerInterruptInit(void)
{
// 注册中断服务函数
IntRegister(C674X_MASK_INT4, TimerIsr);
// 映射中断到 DSP 可屏蔽中断
IntEventMap(C674X_MASK_INT4, SYS_INT_T64P2_TINTALL);
// 使能 DSP 可屏蔽中断
IntEnable(C674X_MASK_INT4);
// 使能 定时器 / 计数器 中断
TimerIntEnable(SOC_TMR_2_REGS, 0x00020000);
}
/****************************************************************************/
/* */
/* 中断服务函数 */
/* */
/****************************************************************************/
void TimerIsr(void)
{
// 禁用定时器 / 计数器中断
TimerIntDisable(SOC_TMR_2_REGS, 0x00020000);
// 清除中断标志
IntEventClear(SYS_INT_T64P2_TINTALL);
TimerIntStatusClear(SOC_TMR_2_REGS, 0x00020000);
// 改变 LED 状态
GPIOPinWrite(SOC_GPIO_0_REGS, 109, Flag);
Flag=!Flag;
GPIOPinWrite(SOC_GPIO_0_REGS, 110, Flag);
// 使能 定时器 / 计数器 中断
TimerIntEnable(SOC_TMR_2_REGS, 0x00020000);
}以上是我设置的64位定时器,我想设置的是每57s触发一次中断,但是现在出现的现象是每18s触发一次中断,高位没有被舍弃,但是每当低位计数到0xffffffff时会触发一次中断,这个是什么原因呢?
我感觉你根本没去找就来问了:
C:\ti\OMAPL138_StarterWare_1_10_03_03\drivers\timer.c
void TimerIntEnable(unsigned int baseAddr, unsigned int intFlags)
{
/* Enable the mentioned interrupts. One or more interrupts are enabled */
HWREG(baseAddr + TMR_INTCTLSTAT) |= intFlags;
}
你好,请问当时高位丢失的问题解决了吗? 我最近也遇到了这个问题,例程中的定时器高位设置不起作用。
timer 64高位问题请参考贴子:
把对TGCR的配置改成下面就没有问题了。
static void TimerSetUp64Bit(void)
{
/* Configuration of Timer */
// TimerConfigure(SOC_TMR_2_REGS, TMR_CFG_64BIT_CLK_INT);
TimerConfigure(SOC_TMR_2_REGS, 3);
/* Set the 64 bit timer period */
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER12, TMR_PERIOD_LSB32);
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER34, TMR_PERIOD_MSB32);
}
也就是new timer plus feature好像有点问题,那就先disable new timer feature吧。