Interrupt programming with BS2
Theo
Posts: 7
Does anyone know if it's possible to use interrupts in PBASIC on the BS2 ?
Thx,
Theo
Thx,
Theo
Comments
Maybe it can be done another way.
Terry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
In my Tachometer app I initialy missed so much an interrupt as to poll the pulses of the sensor on the spinning rotor of my heli...... The COUNT command would take to much time to get a meaning sample to indicate the RPM. Almost all designs i whent trough , relied on an interrupt to the micro.
But there was a solution and it was by changing the sensor. I Used PULSIN instead . That way , in only a very short time I can measure the speed of the rotating triggering device ( Light reflection on an optical switch in this case. )
So with a little imagination there should be an workaround for the missing interrupts ... YES !!!
The wonderfull developing tool the editor is for the Basic Stamp , made the initial tests a breeze ,... just by trial and error procedure.
Francisco
I've·worked with what I call "STAMP Pseudo Interrupts" in the past. It takes a little external circuitry and some code trickery. I have a paper I wrote (long Word document) on the concept that I'd be glad to e-mail to anyone who wants it. (The figures are separate files in CorelDraw)
Basically, you must have external circuitry trigger the STAMP's reset line, and you write your code such that the first line of code is the "interrupt vector"; an unconditional branch to the interrupt service routine. Your main routine needs to be a loop that never normally goes to the first part of the program. When something needs to interrupt, external logic decodes and prioritizes which device has interrupted, pulls the reset line low, and the stamp resets. The program then jumps to an interrupt service routine which might read some input lines to determine what caused the interrupt and service it accordingly.
After the ISR executes, it must reset the external circuitry and return to the main routine.· The only catch is how to download the code initially and get into the main routine loop and bypass the interrupt vector on initial startup. This can be done by having the initial ISR look for yet another input like a pushbutton, and if set, go to the main routine.· The user simply has to hold down the button when the program is first downloaded, and you're off.
Sound complicated? It is! But it does work and was fun to work out. The paper and diagrams make the concept manageable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bruce Clemens, CET Sr.
Instructor, Electronics and Computer Repair Technology
Ozarks Technical Community College
www.otc.edu
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III
National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071
Post Edited (Beau Schwabe) : 9/2/2004 3:03:31 PM GMT
Every other uprocessor I've used had interrupts, so I'll try this on the whiskers.
This way, the bot can be in the "search and avoid" mode always until the whiskers are hit.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard Vannoy
Programming and Electronics Instructor
www.RichardVannoy.info
·
Just change the TestInput to whatever INx you need and adjust the WHILE condition.
' {$STAMP BS2e}
' {$PBASIC 2.5}
TestInput VAR Nib
Main:
DO
DO
'PAUSE 1000
DEBUG BIN4 ? TestInput,CR
DEBUGIN HEX1 TestInput
DEBUG CR
LOOP WHILE TestInput = $f
DEBUG "Pseudo interrupt processing ",CR
DEBUG ? TestInput,CR
LOOP
END