How do I call subroutines from an Interrupt?
I have an sx·program very much like the basic stamp 74HC595 #23 (I beleive) that simple turns 1 LED on in sequence till it reaches the end of the LEDs and then it reverses direction to the begining of the LEDs and repeats itself - like the KIT car lights. I my case I have (5) 8x8 Bidirectional LED Matrixes of which I am wanting to go through all 40 LEDs in the same fashion. My program works so far well. I am not using 74HC595's but Allegro Microsystem A6821's which are almost identical in operation and connections. However, it is more like a serial version of ULN2803's. So now to cycle through 40 LED columns·(*2 because they are bi-colored = 10 A6821's), I only need 3 control lines being CLOCK, DATA IN and STROBE. The A6821's also have /OE to turn on·or off individual A6821's for either RED, GREEN or YELLOW color sets for each LED matrix module.
OK, now that you know a little bit about the hardware and the software which works well, I need to know how to take the main program which calls subroutines and put all of that into an LED scanning routine inside of an interupt. As seen in other LED display programs (like JonnyMac's BADGE.sxb program for the RoboGames medal, a scanning routine is needed inside of an interrupt. Once this is working, I can then send the display messages across the 8 LED Matrix rows (which have P channel FETs for good current control and brightness).
Hopefully you have been able to follow what I am wanting to do and can help. When I try to copy the main program into an Interrupt, it has a problem when trying to call subroutines from within the interrupt. Sure I can not use subroutines and just insert the code directly in, however, the program is large enough to begin with and to add individual routines directly into main program within the Interrupt would make it large and might have some timing issues as it is scanning 40 LED columns.
Any ideas?
Comments..
Thanks for your support.
OK, now that you know a little bit about the hardware and the software which works well, I need to know how to take the main program which calls subroutines and put all of that into an LED scanning routine inside of an interupt. As seen in other LED display programs (like JonnyMac's BADGE.sxb program for the RoboGames medal, a scanning routine is needed inside of an interrupt. Once this is working, I can then send the display messages across the 8 LED Matrix rows (which have P channel FETs for good current control and brightness).
Hopefully you have been able to follow what I am wanting to do and can help. When I try to copy the main program into an Interrupt, it has a problem when trying to call subroutines from within the interrupt. Sure I can not use subroutines and just insert the code directly in, however, the program is large enough to begin with and to add individual routines directly into main program within the Interrupt would make it large and might have some timing issues as it is scanning 40 LED columns.
Any ideas?
Comments..
Thanks for your support.
Comments
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
I tried that but their were SUB errors stating something about the address is not· in the lower half of memory.
Could this be because of the other SUB statements in the program?
I have attached the program. I have copied the information into the ISR Start routine and renamed it.
Please help.
Then, in your main code you wait for the flag, clear it and do whatever you want done on that schedule
You can use that same flag to count ISR activations to create the desired delay.
Subroutine declarations must be in the first half of the code page, your interrupt code pushes them down below that.
P.S. REVERSE is a command, if you make a SUB with the same name, you will not be able to use the REVERSE command in your program. It will always assume you want to call the REVERSE subroutine.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
However, I'm still not sure the interrupt is working. If the Interrupt is set for:
INTERRUPT 10000
Does this not mean that it only run every 10 seconds? Obviously I want to run it faster but as a test I would think this is true. It currently runs like it did before as if it was in a loop or something. The DelayTime it set so that it·cycles on and off·through all 40 leds in·under second or so.
I also am not going to use the REVERSE routine as this was only for testing.
I have attached the modified code.
Thanks.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
The best I have tried so far and very reasonably simple to interface serially via 3 wires only form the SX or any microcontroller. I was able to connect 8 7Segment LED Displays (8x7=56) and manged to control fading, sweep, selective segment control all va serial commands.
Recommendation: Use interrupt only to manage timing and flags in addition to communications
Recommendation: Use an external dedicated chip to drive loads. Preferably one that can be serially controlled.
Recommendation: As I mentioned the Maxim as an example, there are many other chips I have not experimented with yet. Even with the ULN, it does require parallel input so it is not my first choice.
Doing so, I was able to reduce component count and simplify circuitry.
Serially Interfaced, 8-Digit LED Display Drivers. Suprisingly simple to use
Maxim: MAX7219 Attached Documentation
You can Fade, Display BCD, and control display of arrays and matrixes. Biggest advantage is you only need 1 resistor on supply current. this helps alot.
Cheers
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bashar Sadig
Senior Solutions Architect - Enterprise Applications