KlausST
Advanced Member level 7
Him
Thanks BigDog.
Corrected:
24MHz (clock)
24MHz / 6 (cycles per instruction clock) = 4MHz (instruction clock).
2 instruction clocks per dnjz = 2MHz => 500ns
500ns x 10 (mov R6, #10) gives 5.0us
5.0us + 250ns ( mov) additionally = 5.3us
5.3us x 10 (mov R7, #10) = 53.0us.
53us + some +verhead = maybe 55us
--> this is far away from the estimated 100us.
Now when we use SDelay and expect it to last 100us but indeed it takes only 55us then the delay is too short for the display. This may cause the display not to work correctely.
The same is with the other delay routines.
Please review my calculations. And correct the delay setup.
So the correct SDelay code should be:
Please add the new label and the two NOPs to each delay routine.
Klaus
Thanks BigDog.
Corrected:
24MHz (clock)
24MHz / 6 (cycles per instruction clock) = 4MHz (instruction clock).
2 instruction clocks per dnjz = 2MHz => 500ns
500ns x 10 (mov R6, #10) gives 5.0us
5.0us + 250ns ( mov) additionally = 5.3us
5.3us x 10 (mov R7, #10) = 53.0us.
53us + some +verhead = maybe 55us
--> this is far away from the estimated 100us.
Now when we use SDelay and expect it to last 100us but indeed it takes only 55us then the delay is too short for the display. This may cause the display not to work correctely.
The same is with the other delay routines.
Please review my calculations. And correct the delay setup.
So the correct SDelay code should be:
Code:
SDelay: // 10x10 = 100us = 0.1ms
mov R7, #10
DS1: mov R6, #10
DS2: NOP
NOP
djnz R6, DS2
djnz R7, DS1
ret
Please add the new label and the two NOPs to each delay routine.
Klaus