More Serial Interrupt Woes

iGull

New Member
Hi Again :)

Having another issue, this time with HSERIN within my interrupt routine - again, stripped to the bare essentials viz ...

interrupt: hserIn 0,5
gosub beep1
let flags=0
setintflags %00100000,%00100000
return

First time round, interrupt fires on rising edge of received character 1, clocks in 5 characters - beeps - all fine. Second time, nothing. Removing the HSERIN command, it fires every character as expected.
Almost as if the HSERIN is disabling the interrupts somehow.
Debug shows the flags HAVE been set to zero when it returns.

Any thoughts ?

TIA

Neil
 

hippy

Ex-Staff (retired)
It could be that HSERIN is disabling interrupts, certainly ( if I recall your other code correctly, and by your use of interrupts ), you appear to be mixing background receive of serial along with non-background receive with HSERIN which will likely lead to some conflict or other.

Background receive uses the scratchpad as a 'circular buffer', filling it then starting from the bottom again, so guaranteeing any survival of data an explicit HSERIN has placed would be hit and miss. For this reason I'm hesitant to suggest reissuing a HSERSETUP at the end of interrupt, though that may work if HSERIN reads data into scratchpad at a non-zero address, at the end of scratchpad.

I think that whatever you are trying to do needs to be re-thought in terms of background receive or explicit HSERIN use.
 

iGull

New Member
It could be that HSERIN is disabling interrupts, certainly ( if I recall your other code correctly, and by your use of interrupts ), you appear to be mixing background receive of serial along with non-background receive with HSERIN which will likely lead to some conflict or other.
Snip ...
I think that whatever you are trying to do needs to be re-thought in terms of background receive or explicit HSERIN use.
Yes, you're absolutely right - went back to the RTFM mode - re-cobbled the (now fully working) code below - thanks for the pointer (no pun intended :)))

Cheers

Neil

'Serial interrupt routine | Bytes 0+1 = ID(word), 2=CLOCKED, 3=MARKED, 4-19 = FIRST, 21-35=SECOND
interrupt: hserflag=0 'Clear the serial interrupt flag
pause 50 'Long enough for 36 bytes @ 9600 baud
if hserflag=1 then goto interrupt 'In case we didn't catch them all
hserptr=0 'Pointer to the first byte
get 0,WORD ID 'Data address pointer

let WP=0 'Enable e^2 write
for counter = 2 to 35
get counter,temp
writei2c ID, (temp) 'Sadly 10mS/write=0.34secs, but short of building a string variable ....
pause 10 'e^2 settle
inc ID 'Next address
next
let WP=1 'Disable e^2 write
setintflags %00100000,%00100000 'Re-enable HW serial interrupts
let ID=ID-34
'Reset ID
gosub writeLCD 'Display it
gosub beep1 'Annoy someone
return
 
Top