We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi i want delay in ms and us.am using LPC2366.CPU clock: 48MHz.peripheral clock: 12MHz.can any one have source code for delay function.please help me to know how to implement delay function in ms and us.Thanks i advance.
Counting clock cycles in assembler is most definitely affected by the clock speed of the chip, or waitstates of flash, or if caching of flash is done or not.
When the delays are long enough that the function call and timer setup times don't affect the total result too much, they most definitely represent a big advantage. When the delay is long enough that you can wait for an interrupt, instead of busy-polling the timer, you can even conserve power by putting the CPU to sleep.
In short: measuring time with known assembler instructions is better than with an unkonwn C loop. But measuring time with a timer - when possible - solves a lot of problems.
Making life black or white is a boring way to live. There is quite a lot of shades in between too...
Making life black or white is a boring way to live. There is quite a lot of shades in between too... I agree that there is more than one way to skin this cat, timer or assembler delay loop. I also agree that, when long enough, delay by timer is preferrable. HOWEVER I must insist that a delay loop in C is "delay some unknown time" The only C delay loop I would consider (although ridiculous) acceptable would be to figure out how many cycles the most efficient compiler would use and apply that where a delay is only specified as "not less than" and longer delay than minimum is no problem.
a footnote on asembler delays that should ALWAYS have the following $IF (clock == xxx) $else change the code here $endif
Erik