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.
AM5718的DSP核同时使用Timer5和Timer6时,定时器6中断不稳定。
情况如下:
使用Timer6回调函数时,回调函数进入的频率不是设置的频率,但偶尔是正确的。
使用Timer5是正确的。
Timer6回调函数调用Clock_Tick,在任务中每秒打印一次Clock_getTicks(),而从某一时刻开始,定时器触发频率就不稳定了,以下是我调试定时器的过程:
[ 28.000] led 28000...
[ 29.000] led 29000...
[ 30.000] led 30000...
[ 31.000] led 31000...
[ 32.000] led 32000...
[ 33.000] led 33000...
[ 34.000] led 34000...
[ 35.000] led 35000...
[ 36.000] led 36000...
[ 37.000] led 37000...
[ 38.000] led 38000...
[ 39.000] led 39000...
[ 40.000] led 40000...
[ 41.000] led 41000...
[ 42.000] led 42000...
[ 43.000] led 43000...
[ 44.003] led 44003...
[ 45.005] led 45005...
[ 46.007] led 46007...
[ 47.009] led 47009...
[ 48.011] led 48011...
[ 49.013] led 49013...
[ 50.015] led 50015...
[ 51.017] led 51017...
[ 52.019] led 52019...
[ 53.021] led 53021...
[ 54.023] led 54023...
[ 55.025] led 55025...
[ 56.027] led 56027...
[ 57.029] led 57029...
[ 58.031] led 58031...
[ 59.033] led 59033...
[ 60.035] led 60035...
在论坛上已参考:
问题:
1、怎样使定时器稳定触发?
2、AM5718可以使用几个定时器?
这是.cfg的部分代码:
var timer0Params = new Timer.Params();
timer0Params.instance.name = "timer0";
timer0Params.period = 1000;
timer0Params.periodType = xdc.module("ti.sysbios.interfaces.ITimer").PeriodType_MICROSECS;
timer0Params.extFreq.lo = 20000000;
timer0Params.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_CONTINUOUS;
Program.global.timer0 = Timer.create(4, "&TimerFxn", timer0Params);
Clock.tickSource = Clock.TickSource_USER;
Clock.tickPeriod = 1000;
var timer1Params = new Timer.Params();
timer1Params.instance.name = "timer1";
timer1Params.period = 1000;
timer1Params.periodType = xdc.module("ti.sysbios.interfaces.ITimer").PeriodType_MICROSECS;
timer1Params.extFreq.lo = 20000000;
timer0Params.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_CONTINUOUS;
Program.global.timer1 = Timer.create(5, "&clockFxn", timer1Params);
ti_sysbios_timers_dmtimer_Timer.anyMask = 48;
ti_sysbios_timers_dmtimer_Timer.intFreq.lo = 20000000;
ti_sysbios_timers_dmtimer_Timer.timerSettings[4].intNum = 12;
ti_sysbios_timers_dmtimer_Timer.timerSettings[5].intNum = 13;
这是时钟回调函数:
void clockFxn(UArg arg)
{
Clock_tick();
}
论坛那边回复了
1、单独测试过,依然不稳定,并且是时钟并不是偏差几毫秒,而是一瞬间就打印出很多时钟的数据了
2、Clock_tick()是TI-RTOS时钟库函数
请看下面工程师的回复。
Apologies for delay. There is no apparent reason for Timer5 and Timer6 behaving in different manner when both are used in same way. I am trying to reproduce the issue on my end and will soon get back with updates.
Meanwhile, can you check if you are seeing similar behavior with any other timer instance?
我测试使用其他定时器,使用除了Timer0,5,6以外的定时器会导致Linux无法正常工作(或许是我配置的方式不对),而使用Timer0最大频率只能为25971Hz,依然无法稳定输出时钟,也就是说,目前只有一个定时器也就是Timer5在正常工作,当然,这也是所有例程里使用到的定时器。
配置Timer0代码如下,其他定时器类似,只是输入频率不一样(其他的默认20Mhz):
var timer1Params = new Timer.Params(); timer1Params.instance.name = "timer1"; timer1Params.period = 1000; timer1Params.periodType = xdc.module("ti.sysbios.interfaces.ITimer").PeriodType_MICROSECS; timer1Params.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_CONTINUOUS; timer1Params.extFreq.lo = 25971; Program.global.timer1 = Timer.create(0, "&clockFxn", timer1Params); var IntXbar = xdc.useModule('ti.sysbios.family.shared.vayu.IntXbar'); var TimerSupport = xdc.useModule('ti.sysbios.family.shared.vayu.TimerSupport'); TimerSupport.availMask = 0xFFFF;