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?

ソリューションへジャンプ
867件の閲覧回数
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

ラベル(2)
タグ(3)
0 件の賞賛
1 解決策
680件の閲覧回数
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 返答(返信)
680件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

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 件の賞賛
680件の閲覧回数
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 件の賞賛