??? 05/24/06 09:16 Read: times |
#117012 - Russell Sir ... once again have a look Responding to: ???'s previous message |
Respected Russell Sir,
Here are the 2 subroutines again ... pl have a look !!! SUBROUTINE 1 DELAY_MS: MOV R7,#00H LOOPA: INC R7 ; CYCLES = 1 MOV A,R7 ; CYCLES = 1 CJNE A,#0FFH,LOOPA ; CYCLES = 2 RET ; CYCLES = 2 **************************************************************** SUBROUTINE 2 DELAY_HS: MOV R6,#00H ; CYCLES = 1 MOV R5,#002H ; CYCLES = 1 LOOPB: INC R6 ; CYCLES = 1 ACALL DELAY_MS ; CYCLES = 2 MOV A,R6 ; CYCLES = 1 JNZ LOOPB ; CYCLES = 2 DEC R5 ; CYCLES = 1 MOV A,R5 ; CYCLES = 1 JNZ LOOPB ; CYCLES = 2 RET ; CYCLES = 2 ================================================================ Before the two subroutines there are some statements which I am not writing here ... so they also takes some CYCLES ... I'll try to make you understand now ... Sir in the 1st SUBRT the total cycles is 5 excluding RET ie 2 more ... *> It is calculating 256 values ... *> If only 256 cycles is considered then the time delay is 256 microseconds ... ie 1 cycles = 1 microseconds . *> But the delay generated by SUBRTN 1 is 1 MILLISECONDS ie. 1027 cycles ... ie 1027 microseconds Now SUBROTN 2 is also making delay ... but it is making .5 seconds delay ... *> SUBRTN 2 run for two values of R5 -> 2 and 1 ... *> Depending on the value of R5, the value of R6 is incremented two times from 0 to 255 ie. 512 times ... so 512 cycles ... *> But besdies the vbalue of R6 incremented ... the other cycles like : ................................................. LOOPB: INC R6 ; CYCLES = 1 ACALL DELAY_MS ; CYCLES = 2 MOV A,R6 ; CYCLES = 1 JNZ LOOPB ; CYCLES = 2 ............................................... so around 6 cycles each time should be considered when calling to subroutine 1 ... *> If we take this value then it is coming 3080 CYCLES and not 512 cycles for two values of R5 ... ================================================================ Now if take the case ... 3080 * 1027 = 3163160 ... which is 3.16 seconds and if we take only 512 cycles of subrtn 2 then ... 512 * 1027 = 525824 ... which is .5 seconds Now I am sure you mit get my probs ... Waiting for your kind guidance and reply ... Regards Arvind Shrivastava ... |
Topic | Author | Date |
wrong calculation of timer delay ... | 01/01/70 00:00 | |
Comments | 01/01/70 00:00 | |
Russel Sir ... have a look again pl | 01/01/70 00:00 | |
Yes I'm looking | 01/01/70 00:00 | |
Russell Sir ... once again have a look | 01/01/70 00:00 | |
I'm still looking! | 01/01/70 00:00 | |
Try this: | 01/01/70 00:00 | |
Sometimes a Calculator helps![]() | 01/01/70 00:00 |