I have some code for controlling a WS2811 strip.
I have a tactile switch connected to RA0 for control and I have set up an interrupt handler:
Set WPUA0 On
Set IOCAN0 on
On Interrupt PortBChange Call IntSW2
The interrupt occurs and the code jumps to the handler, however it doesn't seem to do anything afterwards.
subIntSW2StopTimer0'Timer0 interrupt is used for data flow control IntOffsetIOCIFOff'Clear IF for IOC repeat PixelCountWS2812SendData(0)'Turn off all the LEDs end repeat wait 3 s Intonend Sub
Have I done something wrong in my code? Once interrupt handler has completed should it just go back to the main code where it left off?
I tried adding a sub (doBounce) at the end of IntSW2 and doBounce does not run when the interrup occurs, however if I put IntSW2 at the top of my code it runs fine.
I am not familiar with the ws2812 code or library. I think the repeat is the problem, perhaps an overflow of the stack there? Set a flag in the interrupt, like ClearLeds = True. Then use a conditional IF ClearLeds = True Then .....Clear the flag and deal with the repeat and wait in Main.
Last edit: kent_twt4 2016-11-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have some code for controlling a WS2811 strip.
I have a tactile switch connected to RA0 for control and I have set up an interrupt handler:
The interrupt occurs and the code jumps to the handler, however it doesn't seem to do anything afterwards.
Have I done something wrong in my code? Once interrupt handler has completed should it just go back to the main code where it left off?
I tried adding a sub (doBounce) at the end of IntSW2 and doBounce does not run when the interrup occurs, however if I put
IntSW2
at the top of my code it runs fine.Full code attached.
Last edit: Peter 2016-11-26
I am not familiar with the ws2812 code or library. I think the repeat is the problem, perhaps an overflow of the stack there? Set a flag in the interrupt, like ClearLeds = True. Then use a conditional IF ClearLeds = True Then .....Clear the flag and deal with the repeat and wait in Main.
Last edit: kent_twt4 2016-11-26
This looks like you are using the same repeat variable - PixcelCount
Yes, the idea was to turn the LEDs off for 3 seconds just as a simple visual indication that the interrupt was working.
See below though vv
It's not the Repeat, or the Wait - I have made the interrupt sub essentially empty and it doesn't return to the main code:
You need clear the correct flag. Datasheet is needed.
SOLVED
You need to clear the IOC flag from RA.0, which is IOCAF0, not the IOCIF flag.