Where is your main loop?Code:DISABLE before here ENABLE after your interrupt subroutine Jump over your interrupt subroutine with a Goto Main or something ON interrupt GOTO GestIntrerupts ' Deal with interrupts ReadSerial: DataRec var byte[5] : DataRec = 0 : PIE1.5 = 1 While CounterA <= 70 : WEND PIE1.5 = 0 ' Disable interrupt on USART FOR COUNTERB=0 to COUNTERA:SEROUT2 SerWRT,16416,[SerDATA(COUNTERB)]:NEXT COUNTERB Goto ReadReadyLoop Not really a good idea inside an interrupt subroutine ' Subroutines Disable ' Don't check for interrupts in this section getbuf: ' move the next character in buffer to bufchar index_out = (index_out + 1):IF index_out > (buffer_size-1) Then index_out = 0 bufchar = buffer[index_out]:Return error: errflag = 0:CREN = 0:CREN = 1:GoTo display ' Carry on buffer_error: errflag.1 = 1:index_in = (index_in - 1) MIN (buffer_size - 1):HSerin [buffer[index_in]] usart_error: errflag.0 = 1 ' Set the error flag for hardware Resume ' Return to program GestIntrerupts: IF INTCON.2 = 1 then T0CON.0 = 0:TMR0L = 0:TMR0H = 0:TimeCount = TimeCount + 1:T0CON.0 = 1:INTCON.2 = 0 ELSE COLON isn't needed but IF RCIF = 1 THEN moved to next line is needed : IF RCIF = 1 THEN IF OERR Then usart_error ' Check for USART errors index_in = (index_in + 1):IF index_in > (buffer_size-1) Then index_in = 0 IF index_in = index_out Then buffer_error ' Check for buffer overrun HSerin [buffer[index_in]]:SEROUT2 SerWRT,16416,[buffer(index_in)]:SerData(CounterA)=buffer(index_in) CounterA = CounterA + 1 IF RCIF Then GestIntrerupts ' Check for another character while we're here ENDIF : ENDIF resume ENABLE
You're using HSerIn with interrupts. HSerIn will wait for the NEXT character into the USART receive register after the interrupt trips.
Lots of little problems with this code...rework it a bit, straighten it out, actually READ thru it from top to bottom and see how it executes, repost, and we'll work it from there...
Bookmarks