I've noticed a problem and can't seem to find an answer. If I run this program everything appears to work great and I get the bytes received back. The problem appears when I trying to send lots of data the program starts to receive and after on or two transmissions is just hangs up and stops responding to data coming in. Anyone have any ideas what might be causing this issue?
Code:DEFINE LOADER_USED 1 DEFINE OSC 16 DEFINE HSER_BAUD 2400 DEFINE HSER_SPBRG 103 ' 19200 Bauds DEFINE HSER_CLROERR 1 ' Automatically clear over-run errors DEFINE HSER_RCSTA 90h ' Enable USART receive DEFINE HSER_TXSTA 20h ' TXSTA=%00100000. TX enable, BRGH=0 for low-speed x var byte ' General purpose variable BytesIn var byte[80] ' Serial array - can receive up to 80 bytes ByteCnt var byte ' Indicates number of bytes in buffer eom con "~" ' End Of Message marker rcif var PIR1.5 ' Alias USART received character interrupt flag bit ByteCnt = 0 ' Zero counter INCLUDE "DT_INTS-18.bas" ' Base Interrupt System INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Receive, PBP, yes endm INT_CREATE ; Creates the interrupt processor INT_ENABLE RX_INT ; enable external (INT) interrupts ENDASM Main: pause 1 goto Main Receive: if rCIF then ' If RCIF=1 there's a new character in RCREG BytesIn[ByteCnt] = RCREG ' Yes. Then store it in array if BytesIn[ByteCnt] = eom then OutMsg ByteCnt = ByteCnt + 1 ' Increment array index pointer endif goto Receive OutMsg: hserout [13,10,dec ByteCnt," Bytes Received",13,10] hserout [str BytesIn\ByteCnt,13,10] for x = 0 to ByteCnt ' Clear array bytes 0 to ByteCnt BytesIn[x] = 0 next x ByteCnt = 0 ' Reset index pointer back to first element while RCIF ' Keep reading until RCIF is clear to flush buffer x = RCREG ' after EOM is received wend @ INT_RETURN




Bookmarks