Using interupts with the BS2p24/40
Donoho
Posts: 3
How can i use interupts with the BS2p24/40?· The frequently asked questions on the website state that the microcontroller itself cannot support interrupts.· Is there an easy way to incorporate interrupts with the use of the BS2?· If not easy, then a good way?· Please reply.· Any helpful advice is well appreciated
Comments
With the BS2p you can setup a polling mode that checks the state of certain pins (you set them up) for certain states (you decide) and takes some action. This is called pin polling. It allows the high level to finish before the pins are scanned and other possible action taken. This is the only way to keep the high-level code working properly. It's not a true interrupt in that the inputs are not scanned until the currently-exectuing instruction is complete. The "POLL" instructions in the Help file can be used to setup pin polling and actions.
That said, often program architecture can help. Here is a structure that I use in many of my programs.
As you can see, the code in the subroutine Background runs every time at the top of the loop.· The variable called task is used to determine what the program does next.· I've made this very simple, but you can add more intelligence to the task updating to handle special conditions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 12/15/2004 6:10:02 PM GMT