Hi,
I have my PIC reading from the PC (VB6 program). The code below makes the PIC wait, after switching on, for "XX-" from the PC and will then execute the line depending on the next character: "a","b" or "c". The start up tone is then heard. OK so far!
However I now wish to loop the program permanently, interrupting to execute the Select Case depending on the "XX-" "a", "b" or "c" character, then going back into the loop until the next "XX-x" is recieved.
My question is: can I use the timeout loop of the HSERIN as I have, if so where am I going wrong? Or do I need to use an interrupt? I have seen some stuff on PIR1.5, ON Interrupt etc but it looks out of my league.
Thanks wise ones!

@ DEVICE HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF,BOD_OFF,PWRT_OF F
'declare variables
define OSC 20
DEFINE HSER_BAUD 19200 'serial
DEFINE HSER_RCSTA 90h 'serial
DEFINE HSER_TXSTA 20h 'serial
VBIn var byte 'for command from VB
MyBuzzer var portb.0 'labelling ports for clarity

trisb = %11000000 ' set port b 0-5 o/ps 6&7 i/ps

mybuzzer = 0 ' buzzer pin 21
VBIn = 0

hserin [wait("XX-"),VBIn] ' wait for XX and VBIn byte- WORKS
pause 10
select case vbin
case "a"
sound mybuzzer,[60,10]
case "b"
sound mybuzzer,[70,15]
case "c"
sound mybuzzer,[70,15,0,15,60,10]
end select

'Start-up beep
sound mybuzzer,[60,10,70,10,80,20]
mybuzzer = 0

'======= Following loop doesn't work ============================

loop:
vbin = 0 ' reset VBIn
pause 10
hserin 10,loop,[wait("XX-"),vbin] ' loops until XX- is read, then waits for rest

select case vbin
case "a"
sound mybuzzer,[60,10]
case "b"
sound mybuzzer,[60,10,70,10]
case "c"
sound mybuzzer,[60,10,0,15,70,10,0,15,80,10]
end select

goto loop
END