StopWatch_DelayUs function is not correct in LPC1830

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

StopWatch_DelayUs function is not correct in LPC1830

544 Views
kensu
Contributor V

Hi, I am using StopWatch_DelayUs API to make delay in LPC1830 MCU application.

I use 5us delay, but the measure is ~120us ( to use GPIO high low), it seems this API is not correct.

But if I use the lpc_chip_18xx StopWatch_DelayMs to make "5ms"  delay. After measure confirm, it is correct.

pastedImage_1.png

Why does the StopWatch_DelayUs not work?

Does LPC1830 not support Us delay?

BTW: my application is debug mode, should I use "release" mode? Does it improve the application performance?

Thanks

Ken

Labels (1)
Tags (2)
0 Kudos
2 Replies

335 Views
soledad
NXP Employee
NXP Employee

Hi,

Unfortunately I cannot to reproduce your issue. I tested using the blinky example from LPCOpen.

You need to consider the time that the instruction to turn/off the PIN requires, this time is not important when you use a (ms) delay, however when you use a (us) delay then this time it is significant. 

I used the OM13076 lpcxpresso 18xx board.

Attached you can find my code.


Have a great day,
Sol

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

0 Kudos

335 Views
kensu
Contributor V

Hi Sol

Thanks for your checking.

I find the cause about "us delay" problem, if I use LPC1857, it works correctly, and if I use LPC1830 it works NG. 

Because the LPC1857 has internal flash and LPC1830 use external flash, I think the instruction fetch is a factor.

After I put the code into SRAM or Config project to Release mode with optimize option, it works correctly.

Thanks

Ken

0 Kudos