| ??? 02/18/03 21:46 Read: times |
#39389 - RE: calculating a delay ms and us Responding to: ???'s previous message |
void 2usdelay(unsigned char d)
{ unsigned char i;
for(i=0;i<d;d++)
}
will still give 3-5 instruction cycles per d value depending on the compiler (version). the only way to get it right is: for 12 MHz clock (you should use 11.0592 instead and adjust the constant 247)
Delay500us: ;call = 2 cycles
mov r0,#247 ; 1 cycle
djnz r0,$ ; 2* 247 cycles
nop ; 1 cycl2
ret ; 2 cycles
; total 500 cycles
Erik |
| Topic | Author | Date |
| calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ms and us | 01/01/70 00:00 | |
| RE: calculating a delay ... addendum | 01/01/70 00:00 | |
RE: calculating a delay ... addendum | 01/01/70 00:00 |



