SerInit:
banksel SPBRG
movlw .25 ;baud rate for 9600 Fosc = 4Mhz
movwf SPBRG ; baud rate
banksel TXSTA
bsf TXSTA, BRGH ; high speed
bcf TXSTA, SYNC ; async mode
banksel RCSTA
bsf RCSTA, SPEN ; enable serial port
bsf RCSTA, CREN ; enable continous receive
GOTO chk
SerRX1:
banksel PIR1
btfss PIR1,RCIF ; Wait until character is received complete 1 byte
goto SerRX1 ;
movf RCREG,W ;store it
movwf store1
return
chk: call SerRX1
movlw 0x03
xorwf store1
btfss STATUS,Z
goto buffer
goto bufferend
buffer: movf store1,w
movwf INDF
INCF FSR,f
goto chk
bufferend:movlw 0x03 ;0x03 ETX
movwf INDF
goto transmit
; [][][][][][][][][][][][][][][][][][][][][][][][][][]
;======================Send Packet====================
; data retrieve
transmit: movlw current_table
movwf FSR
transmit1: movf INDF,w
movwf store
call mt_s
movf INDF,w
xorwf S1
btfsc STATUS,Z
goto stop
incf FSR,f
goto transmit1
mt_s: ;put packet length here to try out maybe is because of packet length that restricted the transmission of data
call mtx_init
movlw 0xAA ;set address byte to 0xAA
movwf mtx_buffer
movf store,w
movwf mtx_buffer1 ;put in data storage
call mtx_send ;call data send routine (encoding)
call Delay50
return