Hello Everybody, I've got a program, that should when it's finished receive a character in the range A-G from the UART, and depending on the character received perform an AD Conversion of one of the pins, and transfer the result back to a PC now I've got the Serial Input Working, and the A/D Conversion, and (some form of transmission back)., but I think theres a problem in my logic to find out what character was being received. I thought that if I took the letter that received (the hex equilanant off anyway) and then checking the set/clear status of the Z bit, then I could find out which letter was received, ie. H'42' - H'42' would equal Z bit set. But that doesn't seem to be happening, can anybody suggest a problem with that, either logically (ie I'm being stupid) or from the code below. Please Help. Andrew. loop call ser_in ; Call ser_in, call doconverstion ; when finished in ser_in goto transmit w goto loop ; when finished transmitted, start ago. ser_in btfsc rcsta,oerr ; does rcsta indicate an overflow error goto overerror ; if so goto overerr btfsc rcsta,ferr ; does rcsta indicate an frameing error goto frameerror ; if so goto frameing error. uart_ready btfss pir1,rcif ; Check If Data Received. goto ser_in ; If Not goback and recheck. uart_gotit bcf intcon,gie ; Clear This Pin btfsc intcon,gie ; Check If Cleared. goto uart_gotit ; If Not Clear reset. movf rcreg,w ; recover UART data bsf intcon,gie ; reanable interrupts movwf rx_data ; save for later return overerror ; This Would Be Called if the UART ; Subsystem went into a failure bcf rcsta,cren ; recover from the error movf rcreg,w ; Flush The Input Buffer movf rcreg,w movf rcreg,w ; As Its Three Deep it will be fine now bsf rcsta,cren ; turn the cren back on. bcf PORTB,7 ; Turn On the LEDS So That A Problem Is Indicated bcf PORTB,5 bsf PORTB,6 movf 'Z',txreg ; Here We Transmit to z to the HOST so that movf 'Z',txreg ; if these are received then the host knows ; that it needs to resend the command. goto ser_in frameerror bcf rcsta,cren ; recover from the error movf rcreg,w ; Flush The Input Buffer movf rcreg,w movf rcreg,w ; As Its Three Deep it will be fine now bsf rcsta,cren ; turn the cren back on. bcf PORTB,7 ; Turn On the LEDS So That A Problem Is Indicated bsf PORTB,5 bcf PORTB,6 movf 'Z',txreg ; Here We Transmit to z to the HOST so that movf 'Z',txreg ; if these are received then the host knows ; that it needs to resend the command. goto ser_in doconverstion bcf pir1,rcif ; Here We Clear The Received Characters Flag, ; Only because we have to do it sometime, and ; to get this far we have to have received a char. movf rcreg,w ; move the received char into the w register subwf 'A',w ; subtract the char received from the contents ; if we received a 'A' zero flag of the status ; register. If we didn;t then it should have skipped btfsc status,Z call do_A_Converstion movf rx_data,w subwf 'B',w ; did we receive a b btfsc status,Z call do_B_Converstion bcf status,z goto ser_in do_A_Converstion movf rcreg,txreg return do_B_Converstion movf rcreg,txreg return -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads