I have a problem with a very simple program which demonstrates a problem with the pause command when interrupts are being used.
The first 3 lines enable a timer interrupt to be generated every 10ms (100Hz)
The main loop flashes a LED on and off every two seconds
The interrupt handler pulses output 3 each time and then re-enables the interrupts.
With the interrupts disables the LED flashes on and off every 2 seconds, HOWEVER, when the interrupts are enabled, the interrupt routine does just what I expect (output 0 is pulsed on/off every 10ms) but the main program loop stops working correctly.
The pause command no longer waits the 1 second, but drops out after approximately 5-10ms and does not wait the defined time. Changing the rate of the interrupt does help either.
Changing the length of the pause does not help either pause 100, pause 1000, pause 10000 all result in the same short delay.
Q1. Am I doing something wrong in the handling of interrupts that may be causing the timing of the pause command to fail?
Or
Q2. Is there a known bug or “feature†that causes this problem?
Many thanks,
Martin
The first 3 lines enable a timer interrupt to be generated every 10ms (100Hz)
The main loop flashes a LED on and off every two seconds
The interrupt handler pulses output 3 each time and then re-enables the interrupts.
With the interrupts disables the LED flashes on and off every 2 seconds, HOWEVER, when the interrupts are enabled, the interrupt routine does just what I expect (output 0 is pulsed on/off every 10ms) but the main program loop stops working correctly.
The pause command no longer waits the 1 second, but drops out after approximately 5-10ms and does not wait the defined time. Changing the rate of the interrupt does help either.
Changing the length of the pause does not help either pause 100, pause 1000, pause 10000 all result in the same short delay.
Q1. Am I doing something wrong in the handling of interrupts that may be causing the timing of the pause command to fail?
Or
Q2. Is there a known bug or “feature†that causes this problem?
Many thanks,
Martin
Code:
Timer=$ffff 'set timer to generate interrupt on next timer overflow
settimer 65385 'set timer frequency to 100hz
setintflags $80,$80 ‘enable timer interrupt
main:
high 0 'turn led on
pause 1000 'wait 1 second
low 0 'turn led off
pause 1000 'wait 1 second
goto main
Interrupt:
high 3 'set output3 high
low 3 'set output3 low
toflag = 0 'clear the timer overflow flag
timer = $ffff 'initialise timer to interupt on next count
setintflags $80,$80 'enable the timer interrupt
return ‘return