delay time coding make me puzzled. for example: void delay() { int x=20000; do{x=x-1;}while(x>1); } how to understand it's delay.and how long time??? sincere your in advance!
Examine the assembly output and count up the instruction cycles.
Remembering of course to take your clock frequency and clock divider into account...
hi, and how long time??? Select correct chip and osc. frequency in the project settings then set two breakpoints before and after delay() and run all in the simulator/debugger. In left field of its window there is "sec" parameter. Write down its value before delay() and calculate delay time at the second breakpoint. By the way, to Keil Support: could it be possible to edit "sec" value, please? At least to clear it manually at any desired time. Regards, Oleg
Please read the instructions immediately above where you typed-in your question - they tell you what to do when posting code. Also see the tips for posting messages: http://www.keil.com/forum/tips.asp When you follow the instructions, your code will retain its formatting, like this:
void delay() { int x=20000; do { x=x-1; } while(x>1); }
wo will try it. thanks for all your help !! Best regards
delay routines should never be written in C they may cange when the compiler is revised. Erik
delay routines should never be written in C Or, to elaborate, delay routines that rely on a processor busy-loop and require precision based on counting instruction cycles are at some degree of risk. Feel free to write delay routines that read a hardware timer in C.