AGCB
Member
Would someone look at this branching code and tell me if there is something wrong.
What I'm trying to do is receive a message from another PIC via USART and then branch accodingly. I have simplified my actual code so you can understand it w/o the whole program. I'm using 18 series chips for both send and receive.
I have reserved 0xfa-ff for instructions. Everything below 0xfa will be displayed as a 3 digit decimal. It works until I add the FB test, then seems to reset or go back to the front of program. I have tried both using interrupts and just polling the receive flag RCIF. The USART part works fine.
What I'm trying to do is receive a message from another PIC via USART and then branch accodingly. I have simplified my actual code so you can understand it w/o the whole program. I'm using 18 series chips for both send and receive.
Code:
usart_in
movf rcreg,w ;get info into wreg
cpfslt number ;if number (0xf9) is less than wreg,(I.E. W is greater)
; skip next instruction
bra set_A
sublw 0xfa ;if wreg is 0xfa
btfsc status,z ;
bra Set_B ;yes, Z is set
sublw 0xfb ;if wreg is 0xfb
btfsc status,z ;
bra Set_C ;yes, Z is set
;other tests for 0xfc-0xff
return
I have reserved 0xfa-ff for instructions. Everything below 0xfa will be displayed as a 3 digit decimal. It works until I add the FB test, then seems to reset or go back to the front of program. I have tried both using interrupts and just polling the receive flag RCIF. The USART part works fine.
Last edited: