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.

SYS/BIOS的CLOCK组件有漂移?

Other Parts Discussed in Thread: TMS320C6747

你好。

硬件平台:TMS320C6747,50M晶振,主频300M;

软件平台:CCS5.5,SYS/BIOS 6.37.5.35,XTOOLS 3.25.6.96

BIOS使能CLOCK、TIMER、还有TimeStamp组件,确认Timer0和Timer1的输入频率为晶振频率50M,在启动BIOS前创建一个Clock:

Error_init(&eb);
Clock_Params_init(&clkParams);
clkParams.period = 5;
clkParams.startFlag = false;
gs_clk = Clock_create(ClockSwiHandler, 100, &clkParams, &eb);
Assert(NULL != gs_clk);

启动Clock_start()该clock后,通过串口输出每次运行时的TimeStamp,发现每次的时间间隔(前后TimeStamp差分)并不是预期的5ms,而是约5.005ms。

还请TI的工程师分析一下这个问题。

------------------------------------------------------------------------------------------------------

使用Timer1_34的HWI来进行相同的处理,发现如下现象:

void timer1_setup(void)
{
static const uint32_t TIMER_PERIOD12 = 50000000u/1000u - 1u;
static const uint32_t TIMER_PERIOD34 = 50000000u/200u - 1u;

tmr1Regs->TCR = 0;
tmr1Regs->TGCR = 0;

tmr1Regs->TGCR |= 0x04;
tmr1Regs->TGCR |= 0x03;

tmr1Regs->PRD12 = TIMER_PERIOD12;
tmr1Regs->TIM12 = 0;
tmr1Regs->PRD34 = TIMER_PERIOD34;
tmr1Regs->TIM34 = 0;

tmr1Regs->TCR &= ~0x1000100;
tmr1Regs->TCR |= 0x800080;
}

上述配置的Timer可以产生预期间隔的中断,前后帧差分后的误差小于1us(最小分辨率)

而周期不减1:

static const uint32_t TIMER_PERIOD12 = 50000000u/1000u
static const uint32_t TIMER_PERIOD34 = 50000000u/200u;

...

产生的现象和使用SYS/BIOS CLOCK模块是相似的。

还请确认下是否是CLOCK模块配置时候减1的问题(按照datasheet的描述应该是减1)。

  • 你好,

    问题正在处理中,你可以到以下链接进行跟进。

    https://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/647806

  • 你好,

    时钟的tickPeriod是多少?是默认的1000usec吗?

  • 是的,保持默认。

  • Hi,

    Let's assume the Clock module is configured to 1ms and you create a new Clock instance (call it foo) to go off every 5 ticks. Let's say you call Clock_start at 10.5 milliseconds after you call BIOS_start. When does foo get called? 

    15 (+small delta) ms foo will be called. Two key points here
    - This is because the tick count was 10 when the Clock instance was started. 10 + 5 is 15.
    - There is a small delta 
      * Since the kernel might be doing work on the Clock tick (e.g. making a task ready since Task_sleep expired)
      * There might be other Clock instances to process first 
      * When the timer interrupt fires, by default a Hwi runs that posts a Swi. The Swi is where all the above work actually occurs. So this adds some overhead.

    20 (+small delta) ms foo will be called. 
    25 (+small delta) ms foo will be called. 
    ...

  • 感谢你的关注,这里我简要描述下当时的状态:

    1)确实还有其他HWI存在,因为UART是中断接收/中断发送的(uartIsr处理HWI,比较耗时的处理放在uartTxSwi和UartRxSwi中,SWI的优先级设定为3),共3个UART全双工工作;

    2)当时只有一个5ms的Clock实例运行,我需要一个200HZ的周期事件,显然硬件定时器HWI也能满足,但我不希望HWI太多,所以想试试Clock模块;

    3)200HZ周期事件CLOCK模块或TIMER的HWI所指向的回调函数(可能不叫回调函数)会调用Mailbox_post(midGiDataSrc, (Ptr)&msg, BIOS_NO_WAIT),打时间标记是在另一个任务中使用Timestamp模块提供的API,Timestamp_get64(),5ms的时间间隔和5.005ms的时间间隔就发生在使用TIMER的HWI和使用CLOCK模块上,其他的条件是一样的,所以我会怀疑Clock模块和Timer的HWI的差别;

    4)按照以往的调试经验,不使用硬件方法(硬件TIMER中断或外部FPGA中断)去追求us级别的定时精度是不实际的,而当时的环境也不够纯净,存在多个HWI、SWI,在打timestamp之前还发生Mailbox_post以及任务的切换;

    最后还是感谢你们的关注。