In K10 microcontroller how can we get a real time delay like delayms(100) or delayus(100) for 100 ms and 100 us delay?

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

In K10 microcontroller how can we get a real time delay like delayms(100) or delayus(100) for 100 ms and 100 us delay?

跳至解决方案
868 次查看
psjhawer
Contributor II

Hi All,

I'm using an MK10DX128VLH5 IC in my project. I want to give a delay of exactly 3 secs in between 2 operations. Is there an inbuilt function or something that can give me this exact delay??.

Meanwhile if u guys can help me with the amount of delay the followingfunction gives when run, it would help me solve the issue more easier. The following code is already used in an existing code which i need to change for an upgraded product.

Delay_t(20000);

void Delay_t(unsigned int i){

  int k;

while(i--){

    for(k=0;k<10;k++){ 

  asm ("NOP");

    }

  }

}

The CPU Configuration is as follows:

pastedImage_1.png

Please help ASAP. Plz let me know if any other information is required..

Thanks in advance,

Prafful

标记 (3)
0 项奖励
1 解答
681 次查看
santiago_gonzal
NXP Employee
NXP Employee

Hello,

In embedded projects usually you don't block the MCU to wait for such big amounts of time. Instead you can use a timer to get notified via an interrupt after the time has passed.

This tutorial will help you:

http://mcuoneclipse.com/2012/08/13/tutorial-timer-led-with-processor-expert-for-kinetis/

Regards,

Santiago

在原帖中查看解决方案

0 项奖励
3 回复数
681 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Prafful,

Santiago illustrated one way to get precise delay, and I'd like to suggest that you can also use the systick timer to implement precise delay.

You could check the detail description of systick timer through the thread as follow.

Where is detail description for Systick for KL?
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

682 次查看
santiago_gonzal
NXP Employee
NXP Employee

Hello,

In embedded projects usually you don't block the MCU to wait for such big amounts of time. Instead you can use a timer to get notified via an interrupt after the time has passed.

This tutorial will help you:

http://mcuoneclipse.com/2012/08/13/tutorial-timer-led-with-processor-expert-for-kinetis/

Regards,

Santiago

0 项奖励
681 次查看
psjhawer
Contributor II

Thanks for your reply santiago.gonzalez The timer inturrupt was very helpful and made my day. :smileyhappy: The tutorial u suggested was also very helpful. Thanks once again..

Regards,

Prafful

:smileyhappy::smileygrin::smileyhappy:

0 项奖励