Clock drift in tickless idle mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Clock drift in tickless idle mode

跳至解决方案
1,608 次查看
evgenyerlihman
Contributor IV

Hello,

From what i understand, please correct me if i am wrong, the lptmr was added to tickless idle  to minimize time drift during sleep. But from the following comment i can understand the some drift is still possible:

/* Stop the LPTMR and systick momentarily. The time the LPTMR and systick is stopped for
is accounted for as best it can be, but using the tickless mode will
inevitably result in some tiny drift of the time maintained by the
kernel with respect to calendar time. */

I have two questions:

1. What is the drift that i should expect in this case?

2. If i need to use LPTMR for other purposes, and will be using fsl_tickless_systick instead of fsl_tickless_lptmr. What is the drift that i should expect in this case?

Thanks,

Evgeny

1 解答
1,214 次查看
BlackNight
NXP Employee
NXP Employee

Hi Evgeny,

regardless what timer you are going to use, you will have some drift. The drift is caused by the fact that in tickless idle mode the timer is not continuously running, but the RTOS has to

a) stop the timer

b) update the timer modulo register with the new value

c) restart the timer

This for every tickless timer interrupt. Now how much the drift will be depends on the timer interrupt frequency.

The LPTMR adds some extra drift because the minimal time for the tick is 1 ms. So in the worst case you will be off up to 1ms for every timer tick. In my applications I have a drift in the range of or 10% using LPTMR, and in the range of 2-5% for high frequency SysTick timer.

Note that you can add a compensation with using configSTOPPED_TIMER_COMPENSATION.

More infos: Tickless Low power features in FreeRTOS and Low Power with FreeRTOS: Tickless Idle Mode | MCU on Eclipse 

I hope this helps,

Erich

在原帖中查看解决方案

1 回复
1,215 次查看
BlackNight
NXP Employee
NXP Employee

Hi Evgeny,

regardless what timer you are going to use, you will have some drift. The drift is caused by the fact that in tickless idle mode the timer is not continuously running, but the RTOS has to

a) stop the timer

b) update the timer modulo register with the new value

c) restart the timer

This for every tickless timer interrupt. Now how much the drift will be depends on the timer interrupt frequency.

The LPTMR adds some extra drift because the minimal time for the tick is 1 ms. So in the worst case you will be off up to 1ms for every timer tick. In my applications I have a drift in the range of or 10% using LPTMR, and in the range of 2-5% for high frequency SysTick timer.

Note that you can add a compensation with using configSTOPPED_TIMER_COMPENSATION.

More infos: Tickless Low power features in FreeRTOS and Low Power with FreeRTOS: Tickless Idle Mode | MCU on Eclipse 

I hope this helps,

Erich