Subroutine call inside an ISR
SelfPropelled
Posts: 6
It appears that calling a Subroutine from an Interrupt causes problems.
The SUB directive occurs after the ISR routine, so the Sub call generates
an 'unkown command' error.
Moving the SUB directive above the ISR routine causes other problems.
Am I missing something?
[noparse][[/noparse]code]
'==========================================================================
' INTERRUPT
'
ISR_Start:
PULSOUT RA.0, 1000 'FLASH TEST LED
PULSOUT RA.1, 1000
PULSOUT RA.2, 1000
READKEY ' <<< THIS GENERATES COMPILER ERROR 'UNKNOWN COMMAND'
ISR_Exit:
Keys = %0000_0000 'Set Key Row Drive low for WKED
WakePend = %0000_0000 'CLEAR INTERRUPT PENDING FLAG.
RETURNINT
'=========================================================================
PROGRAM Start
'=========================================================================
'
' Program Code
'
READKEY SUB 0 ' <<< Is this in the right place?
Start:
TRIS_Keys = %1111_0000 ' refresh IO state
Keys = %0000_0000 ' Set Key Row Drive low for WKED
WKED_B = %1111_1111 ' Falling edge detect
WKEN_B = %0000_1111 ' Use bits 4-7 for inputs
ST_B = %0000_1111 ' Bits 4-7 are Schmitt Trigger Inputs
'...
'
SUB READKEY
.
.
.
ENDSUB
'=============================================================
The SUB directive occurs after the ISR routine, so the Sub call generates
an 'unkown command' error.
Moving the SUB directive above the ISR routine causes other problems.
Am I missing something?
[noparse][[/noparse]code]
'==========================================================================
' INTERRUPT
'
ISR_Start:
PULSOUT RA.0, 1000 'FLASH TEST LED
PULSOUT RA.1, 1000
PULSOUT RA.2, 1000
READKEY ' <<< THIS GENERATES COMPILER ERROR 'UNKNOWN COMMAND'
ISR_Exit:
Keys = %0000_0000 'Set Key Row Drive low for WKED
WakePend = %0000_0000 'CLEAR INTERRUPT PENDING FLAG.
RETURNINT
'=========================================================================
PROGRAM Start
'=========================================================================
'
' Program Code
'
READKEY SUB 0 ' <<< Is this in the right place?
Start:
TRIS_Keys = %1111_0000 ' refresh IO state
Keys = %0000_0000 ' Set Key Row Drive low for WKED
WKED_B = %1111_1111 ' Falling edge detect
WKEN_B = %0000_1111 ' Use bits 4-7 for inputs
ST_B = %0000_1111 ' Bits 4-7 are Schmitt Trigger Inputs
'...
'
SUB READKEY
.
.
.
ENDSUB
'=============================================================
Comments
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
In the interrupt section -- this is the only thing there. Somewhere in your listing (usually after the main body of the program) you'll have this:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Much appreciated.
Mike
I missed your reply earlier.
Nice approach.
Thanks very much.