rolfi@tisco.no
Member
I am using PE 5.5.1 trying to obtain communication btw a 20x2 (vs.c.0) based "box" and a pc/windows application. My idea is to use the axe027 cable btw the two, and use serrxd and sertxd on the picaxe side. The pc-application (written in ROBOTbasic) is to be the master, and send commands w/parameters to the picaxe, with pinb.0 (hwint1) hooked directly to the Serial In pin (icp2). Most of this works nicely, - except the interrupt part. I have tried hard to understand what the manual says about the interrupt system, but not much success. For example, what is the precise relationship btw. HintSetup and SetIntFlags?
I have searched the forum, I found this thread from 22-04-2012 "Need a good way to handle multiple interrupts". #4 by westaust55:
Even if this code is not dealing with hwint1, I guess it is relevant, because it deals with a hardware interrupt. So, I tried something similar with hwint1, but had to include 'HintSetup' in the setup part of the code, and 'SetIntFlags %0000010, %00000010' in the service routine.. Why? And bit 5 in the HintSetup seems to be in conflict with the Setintflags flags byte (bit1 =1. Or Did I misunderstand these bits?
Anyway, here is my attempt to have a hwint1 interrupt, triggered from the Serin In - pin, put together on a AXE091 board:
which works consistently running on an AXE091 board when I use an electronically debounced switch hooked up to pinb.0/hwint1. But as soon as I connect Serial In to the hwint1/b.0-pin, and send chars from the terminal in order to trigger hwint1, the interrupt only happen now and then. Why? (I've checked the signals with a scope .. seems ok) And, very surprising, rubbish is sent back to the pc/terminal immediately. (This is very bad for my application, It also, of course , appears on an oscilloscope) This rubbish is itself a mystery to me, how can THAT happen? (I know I can probably find a way around this, but I really want to understand what happens) .. I am really stuck ... any help is highly appreciated!!
I have searched the forum, I found this thread from 22-04-2012 "Need a good way to handle multiple interrupts". #4 by westaust55:
Code:
SETINTFLAGS OR %10100000,%10100000 ; to set interrupt on background hardware serial receive or timer 0 overflow
do
loop
Interrupt:
IF ToFlag = 1 THEN
; do timer interrupt procvessing - or set/increment a flag for the main loop to continue processing
; let toflag = 0 ; to clear the flag if required
ELSE IF hserflag = 1 THEN
; do background receive processing - or set/increment a flag for the main loop to continue processing
; the value ‘hserptr -1’ indicates the last byte written, and ‘hserinflag = 1’ indicates a byte has been received
; let hserflah = 0 ; to clear the flag if required
ENDIF
RETURN
Anyway, here is my attempt to have a hwint1 interrupt, triggered from the Serin In - pin, put together on a AXE091 board:
Code:
#picaxe 20X2
#No_data
#No_table
#terminal 19200 ;bec setfreq m16
setfreq m16
IOinit:
dirsB=%11111110 ;b0,4 in. Rest OUT
dirsC=%11111111 ;No floating inputs to be sure..
pinsC=$ff
Intrrptinit: ;Init HWint1
HintSetup %00100010 ;No intrrpt without it
SetIntFlags %00000010, %00000010;No intrrpt without it
;*************************************************************************
main:
goto main
;
;***********************************************************************
Interrupt: ;triggered from pinb.0 fed by a (physically debounced) sw
; on the AXE091 board. Or from Serin In
sertxd(#flags) ;Shows Hint1Flag and Hintflag set
toggle b.1 ;To a LED, for recognisable action
Hint1Flag=0 ;if omitted continuous interrupts, that is understandable..
SetIntFlags %00000010, %00000010 ;No intrrpt without this, either
Return