Hi
I'm noticing some weird behaviour using an interrupt with parallel processing.
This code looks for an input on C.1, then triggers into the interrupt. But instead of pausing at the line "pause 1000" it goes immediately to the next line.
If you comment out the start1 / goto start1 lines (thus switching to single task mode), the program does indeed pause correctly at the pauses in the interrupt subroutine.
It happens in the simulator but also in hardware. I'm using an 18M2 but have tried 14M2 and 20M2 in the simulator which exhibit the same behaviour.
I assumed the problem was something to do with this (manual 1 p63):
"The start (“top”) of the program is always task 0. This is the first task that is started when the chip is reset."
So I thought that maybe when the interrupt is called, multithreaded task 0 goes back to the top of the program and retriggers the setint command, which would skip straight out of the pause.
However, also according to the manual (parallel processing section):
"There is one interrupt (setint command) which will interrupt all current tasks."
So all tasks should be suspended upon interrupt. I tried adding various things like
at the top of the interrupt subroutine but it still doesn't pause.
I also brought the setint command into the start1 task, and using start0, but still no pause.
Anyone any ideas why this is happening and/or how to get it to pause in the interrupt?
As I'm sure the first question everyone will ask is, what is the application? Obviously the code above can be done without multithreading. I'd prefer not to list my application, it's 3-4 pages of code at the moment, if I post that, everyone will focus endlessly on its quirks and talk about alternative ways of doing it. I've stripped down the code above to the bare minimum in order to isolate the problem, hopefully we can focus on that instead.
I'm noticing some weird behaviour using an interrupt with parallel processing.
This code looks for an input on C.1, then triggers into the interrupt. But instead of pausing at the line "pause 1000" it goes immediately to the next line.
Code:
setint %00000010,%00000010, C ' look for a high input on pin C.1
loop1: ' parallel task 0
' do nothing
goto loop1:
start1: ' parallel task 1
' do nothing
goto start1
interrupt:
high 1
pause 1000 ' no pause here
low 1
pause 1000 ' or here
setint %00000010,%00000010, C ' set the same interrupt
return
If you comment out the start1 / goto start1 lines (thus switching to single task mode), the program does indeed pause correctly at the pauses in the interrupt subroutine.
It happens in the simulator but also in hardware. I'm using an 18M2 but have tried 14M2 and 20M2 in the simulator which exhibit the same behaviour.
I assumed the problem was something to do with this (manual 1 p63):
"The start (“top”) of the program is always task 0. This is the first task that is started when the chip is reset."
So I thought that maybe when the interrupt is called, multithreaded task 0 goes back to the top of the program and retriggers the setint command, which would skip straight out of the pause.
However, also according to the manual (parallel processing section):
"There is one interrupt (setint command) which will interrupt all current tasks."
So all tasks should be suspended upon interrupt. I tried adding various things like
Code:
suspend 0
suspend 1
setint OFF
I also brought the setint command into the start1 task, and using start0, but still no pause.
Anyone any ideas why this is happening and/or how to get it to pause in the interrupt?
As I'm sure the first question everyone will ask is, what is the application? Obviously the code above can be done without multithreading. I'd prefer not to list my application, it's 3-4 pages of code at the moment, if I post that, everyone will focus endlessly on its quirks and talk about alternative ways of doing it. I've stripped down the code above to the bare minimum in order to isolate the problem, hopefully we can focus on that instead.