techElder
Well-known member
Does anyone see what I'm doing incorrect here? PE6 Terminal is receiving the text within the DO/LOOP, and I have an LED on my AXE091 board showing the heartbeat of portB.
I can't seem to get an interrupt to function. It works in the simulator in another program. I copied into a new program to get the hardware comms working, but seem to have lost the interrupt function.
I can't seem to get an interrupt to function. It works in the simulator in another program. I copied into a new program to get the hardware comms working, but seem to have lost the interrupt function.
Code:
[color=Navy]#picaxe [/color][color=Black]40X2 [/color][color=Green]; Set the compiler mode, also the equivalent of #define xxx.[/color]
[color=Navy]#no_table [/color][color=Green]; Do not download table or EEPROM data (X1 and X2 parts only).
; This automatically also enables #no_data'[/color]
[color=Navy]#slot 0 [/color][color=Green]; Select internal program slot (0-3) or i2c slot (4-7) on X2 parts.[/color]
[color=Navy]#define [/color][color=Black]CLOCK [/color][color=Blue]EM32 [/color][color=Green];SEE NOTE ; EM must be there or runs on internal resonator[/color]
[color=Navy]#terminal 9600 [/color][color=Green]; off/300/600/1200/4800/9600/19200/38400
'[/color]
[color=Blue]SETFREQ EM32[/color]
[color=Purple]dirsB [/color][color=DarkCyan]= [/color][color=Navy]%11111111 [/color][color=Green]; all outputs PERF bus[/color]
[color=Blue]Hsersetup B9600_32[/color][color=Black], [/color][color=Navy]%111[/color]
[color=Blue]setintflags [/color][color=Navy]%00100000[/color][color=Black],[/color][color=Navy]%00100000 [/color][color=Green]'// interrupt on hserial receive [/color]
[color=Black]Main:[/color]
[color=Blue]do [/color][color=Green]; Main program loop
' Loop while waiting for stuff from the serial hardware interrupt
[/color][color=Purple]pinsB [/color][color=DarkCyan]= [/color][color=Navy]%11111111 [/color][color=Green]; lamps ON
[/color][color=Blue]pause [/color][color=Navy]2000 [/color][color=Green]; 1/2 second
[/color][color=Purple]pinsB [/color][color=DarkCyan]= [/color][color=Navy]%00000000 [/color][color=Green]; lamps OFF
[/color][color=Blue]pause [/color][color=Navy]2000 [/color][color=Green]; 1/2 second
'sertxd ("This is something.", cr,lf)
[/color][color=Blue]hserout [/color][color=Navy]0[/color][color=Black], [/color][color=Blue]([/color][color=Red]"hserptr: "[/color][color=Black],#[/color][color=Purple]hserptr[/color][color=Black], [/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)[/color]
[color=Green]' hserout 0, ("flags: ",#flags, cr,lf)[/color]
[color=Blue]loop [/color][color=Green]; End of main program loop[/color]
[color=Blue]end[/color]
[color=Green]'---------------------------
[PLAIN]'------[ SUBROUTINES ]------[/PLAIN]
'---------------------------
'[/color]
[color=Blue]Interrupt: [/color][color=Green]' COMMAND
'
[/color][color=Blue]gosub [/color][color=Black]showSomething [/color][color=Green]; Go while interrupted, return here
[/color][color=Purple]flags [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Green]; Clear the hserint flag
[/color][color=Blue]setintflags [/color][color=Navy]%00100000[/color][color=Black],[/color][color=Navy]%00100000 [/color][color=Green]; re-enable interrupt on serial receive [/color]
[color=Blue]return [/color][color=Green]; Back to main[/color]
[color=Black]showSomething:[/color]
[color=Green]' sertxd (7, cr,lf)
' sertxd ("Interrupted.", cr,lf)
[/color][color=Blue]hserout [/color][color=Navy]0[/color][color=Black], [/color][color=Blue]([/color][color=Red]"Interrupted..."[/color][color=Black], [/color][color=Blue]cr[/color][color=Black],[/color][color=Blue]lf)
return[/color]
Last edited: