*bump* So, with the following code, a lot of the problems are ameliorated, but for example in the speed test program, the transmitter will reliably eventually get stuck with the interrupt disabled. I can't imagine how that's possible.
Code:
Edit: @Calc84: Just to be clear, your code chunk is meant to go at the beginning of the particular routine to be protected, correct? And its output can be pushed and popped around the protected routine and used to re-enable interrupts at the end?
Code:
#endif ;cn2_installerinflash
ld a,%00001000 ;Acknowledge and disable ;2
out (3),a ;2
ld a,%00001010 ;Set 1st timer active ;2
out (3),a ;2
ld a,%00000000 ;Fastest frequency, ~560hz ;2
out (4),a ;2
Cn2_NextTickLoop:
in a,(4) ;2
and %00000010 ;2
jr z,Cn2_NextTickLoop ;2
ld a,%00001000 ;Acknowledge and disable ;2
out (3),a ;2
ld a,%00001010 ;Set 1st timer active ;2
out (3),a ;2
ld a,%00000110 ;Slowest frequency, ~110hz ;2
out (4),a ;2
exx ;1
ex af,af' ;1
ei ;1
reti ;-1-8- -1-9- -9- -4-2- 55 bytes total now ;1
Cn2_Caller_RoutineDone:
Edit: @Calc84: Just to be clear, your code chunk is meant to go at the beginning of the particular routine to be protected, correct? And its output can be pushed and popped around the protected routine and used to re-enable interrupts at the end?