Chunhee Song wrote: > > Thank you, Tony for giving me an idea how to receive two byte data. I > hope anyone has time to look at my code and point out what's wrong with > it. > I would like to receive 3 bytes. First two bytes are for duty cycle and the > third one is for direction. I looked at my PIC book and piclist but > couldn't find how to process input data. 7f+ is transferred from PC to > pic. 7f is duty cycle and + is clockwise. Pic doesn't seem to take f as > binary "1111" for sure. btfss pir1,rcif ; got a char? goto noChar ; no ; ; Data for duty cycle ; Eg. 7F = 127dec -> PC sends chr(127) not '7' + 'F' ; movf RCREG,W movwf DutyCycle ; ; Now get direction, should be following DutyCycle data ; 0 = Anti-clockwise, non zero = Clockwise ; CharWt btfss pir1,rcif ; wait for next char goto CharWt movf RCREG,W ; get direction byte btfss STATUS,Z goto ClockWise ; ; 0 = AntiClockwise move ; .... ; ; non 0 = Clockwise move ; ClockWise .... -- Best regards Tony http://www.picnpoke.com mailto:sales@picnpoke.com