s32k144 时延函数

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

s32k144 时延函数

361 次查看
fengba
Contributor I

I would like to implement a function that can generate a delay of 1 microsecond (1us) and 1 millisecond (1ms). Could you please tell me the methods or provide example code?

0 项奖励
回复
1 回复

344 次查看
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @fengba,

Please take a look into the OSIF module, function void OSIF_TimeDelay(const uint32_t delay).

Julin_AragnM_0-1718126761385.png

The reload value of the SysTick is the core frequency divided by 1000, that means that the Systick interrupt is called every 1ms and increment the s_osif_tick_cnt counter.

The counter is then read and compered by the OSIF_TimeDelay() function.

If the core frequency was divided by 10000, the counter would increment every 100us (OSIF_TimeDelay(1) = 100us).

The SysTick description can be found in ARM documentation: Cortex™-M4 Devices Generic User Guide, Section 4.4 System timer, SysTick.

Best regards,
Julián

0 项奖励
回复