If an interrupt handler invokes LockTask immediately after a WaitForInterrupt(zxPinLow), and does not UnlockTask before reinvoking the WaitForInterrupt with a still-low pin, will the WaitForInterrupt be immediately satisfied before another task might get a tick?
Tom
Low level Int
Sorry. It is a task on a ZX-24a that watches two axes in quadrature at ~2kHz combined edge rate. The interrupt line is the output of a four-bit comparator, four from the quadrature sensors, four from the processor. At each interrupt, code determines the appropriate axis counts, and acks the quadrature changes by matching them on the comparator, which would then normally raise the Int line (to inactive).
If another quadrature change occurs during the processing of one interrupt, the Int line will remain active (low). Will there be a potential task switch at the next WaitForInterrupt if LockTask is still in effect for that task?
If another quadrature change occurs during the processing of one interrupt, the Int line will remain active (low). Will there be a potential task switch at the next WaitForInterrupt if LockTask is still in effect for that task?
Tom
After reviewing the code, I'm convinced that the task awaiting the interrupt would remain in control.GTBecker wrote:Will there be a potential task switch at the next WaitForInterrupt if LockTask is still in effect for that task?
I believe that the test code below proves that task1 remains in control with the Int0 input grounded, effectively starving out Main. When run, the red LED remains illuminated as long as task1 remains in complete control.
Code: Select all
Dim ts1(1 to 200) as Byte
Dim state as Byte
Sub Main()
state = 0
Call PutPin(Pin.RedLED, zxOutputHigh)
Call PutPin(Pin.GreenLED, zxOutputHigh)
CallTask task1, ts1
Do While (state <= 1)
Call Sleep(0.1)
state = 1
Loop
Call PutPin(Pin.GreenLED, zxOutputLow)
End Sub
Sub task1()
Call PutPin(Pin.RedLED, zxOutputLow)
Do While (state = 0)
Call WaitForInterrupt(zxPinLow, 0)
Call LockTask()
Loop
Call PutPin(Pin.RedLED, zxOutputHigh)
state = 2
End Sub
- Don Kinzer