??? 07/25/05 13:07 Modified: 07/25/05 13:15 Read: times |
#97994 - Wrong ! Responding to: ???'s previous message |
mov r0, #HIGH ms 00001$: mov r1, #LOW ms 00002$: nop nop djnz r1, 00002$ djnz r0, 00001$ retYour delay routine will not function well. What if LOW ms is a small number: 1, 2 ... ? You reload R1 with it, so the delay is equally dependent on lower byte as on higher ! The exact routine should look like this: MOV R0,#HIGH INC R0 ; In case of HIGH=0, R0 must be 1 ; to go out from the loop immediately ! MOV R1,#LOW INC R1 ; Same as up DLY: NOP DJNZ R1,DLY DJNZ R0,DLYThis way, the DLY loop will be performed (LOW + HIGH * 256) times. Exactly what we need. Regards, Slobodan |