定时中断功能

[复制链接]
 楼主| zhanghqi 发表于 2016-7-10 15:27 | 显示全部楼层 |阅读模式
最近入手OMAP-138,我想用DSP核实现一个定时中断功能。参考SEED提供的开发包,写了一个测试代码。
 楼主| zhanghqi 发表于 2016-7-10 15:28 | 显示全部楼层
发现,将TIMER0配置成32位,非关联模式后,TIMER3:4运行正常,但是TIMER1:2不运行。
wuhany 发表于 2016-7-10 15:30 | 显示全部楼层
代码设置代码看看
 楼主| zhanghqi 发表于 2016-7-10 15:32 | 显示全部楼层
稍等
 楼主| zhanghqi 发表于 2016-7-10 15:33 | 显示全部楼层

uint32_t USTIMER0_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;
// TMR0->PRD34 = 0xFFFFFFFF;

   TMR0->TIM12 = 0x00000000;
   TMR0->PRD12 = 0x00000000;
   // start timer0 - 3:4.
// SETBIT(TMR0->TCR, ENAMODE34_CONT);

   return (ERR_NO_ERROR);
}


void USTIMER0_delay(uint32_t in_delay)
{
    uint32_t regData;
#if 0

    // stop the timer, clear int stat, and clear timer value.
    CLRBIT(TMR0->TGCR, TIM34RS);
    TMR0->TCR = 0x00000000;
    SETBIT(TMR0->INTCTLSTAT, PRDINTSTAT34);
    TMR0->TIM34 = 0x00000000;

    // setup compare time.

    TMR0->PRD34 = TICKS_PER_US * in_delay;

    // start timer1 - 3:4 to run once up to the period.
    SETBIT(TMR0->TCR, ENAMODE34_ONETIME);
    SETBIT(TMR0->TGCR, TIM34RS);

    // wait for the signal that we have hit our period.
    while (!CHKBIT(TMR0->INTCTLSTAT, PRDINTSTAT34));
#else
    // stop the timer, clear int stat, and clear timer value.
    CLRBIT(TMR0->TGCR, TIM12RS);
    TMR0->TCR = 0x00000000;
    SETBIT(TMR0->INTCTLSTAT, PRDINTSTAT12);
    TMR0->TIM12 = 0x00000000;

    // setup compare time.
    TMR0->PRD12 = TICKS_PER_US * in_delay;

    CLRBIT(TMR0->TCR,CLKSRC12);
    CLRBIT(TMR0->TCR,TIEN12);

    // start timer1 - 3:4 to run once up to the period.
    SETBIT(TMR0->TCR, ENAMODE12_ONETIME);
    SETBIT(TMR0->TGCR, TIM12RS);

    // wait for the signal that we have hit our period.
    while (!CHKBIT(TMR0->INTCTLSTAT, PRDINTSTAT12));
#endif
}

主函数

main()
{
    USTIMER0_init();
    printf("the timer0 test start\n" );
    USTIMER0_delay(100);
    printf("the timer0 test end\n");
}
jiaxw 发表于 2016-7-10 15:35 | 显示全部楼层
如果使用timer3:4来实现,这个测试函数就可以走完吗?
 楼主| zhanghqi 发表于 2016-7-10 15:37 | 显示全部楼层
可以走完
zhaoxqi 发表于 2016-7-10 15:39 | 显示全部楼层
用timer1:2来做呢
 楼主| zhanghqi 发表于 2016-7-10 15:42 | 显示全部楼层
不行
 楼主| zhanghqi 发表于 2016-7-10 15:44 | 显示全部楼层

根据TI,定时器的 资料上配置了内部时钟源,禁止了内部时钟源开关就是始终不往下运行!
 楼主| zhanghqi 发表于 2016-7-10 15:45 | 显示全部楼层
还需要配置什么吧
jlyuan 发表于 2016-7-10 15:46 | 显示全部楼层
检查Linux启动了没有
heweibig 发表于 2016-7-10 15:49 | 显示全部楼层
timer1:2中的一个被Linux当系统定时器用了
jiahy 发表于 2016-7-10 15:50 | 显示全部楼层

另一个在内核中好像是被Ban了。
jiaxw 发表于 2016-7-10 15:52 | 显示全部楼层
把这个定时器设置为DSP使用
 楼主| zhanghqi 发表于 2016-7-10 15:54 | 显示全部楼层
我的DSP端软件是裸跑的!
结贴了
angerbird 发表于 2016-7-11 15:17 | 显示全部楼层
定时中断功能的还是比较简单的啦
Thor9 发表于 2016-7-12 21:15 | 显示全部楼层
这到底是什么原因呢
迪卡 发表于 2016-7-14 19:16 | 显示全部楼层
Linux启动了没
chuntian2016 发表于 2016-7-15 17:09 | 显示全部楼层
那就实现定时启动打开相关的中断不就OK了么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

852

主题

11757

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部

852

主题

11757

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部