Hi,
There is a lot of info on various ways to convert pic hex values to ascii for transmission to the PC.
However I'm looking at sending multiple control values from the PC to the Pic for Timers and Temp control such as 19:21, 14.2c and function controls with Y or N.
The basic way I can see to do it is, if its not a Y or N character then store the next 1 ,2 or 3 bytes in registers until CR is sent, then use an ascii to hex converter.
While it works, it does seem a long hard way of doing things, so wondered what kind of methods other members use and if there are some easier ways of doing this type of data transfer.
A handy snippet of working code I found
There is a lot of info on various ways to convert pic hex values to ascii for transmission to the PC.
However I'm looking at sending multiple control values from the PC to the Pic for Timers and Temp control such as 19:21, 14.2c and function controls with Y or N.
The basic way I can see to do it is, if its not a Y or N character then store the next 1 ,2 or 3 bytes in registers until CR is sent, then use an ascii to hex converter.
While it works, it does seem a long hard way of doing things, so wondered what kind of methods other members use and if there are some easier ways of doing this type of data transfer.
A handy snippet of working code I found
Code:
ASCSum2Hex ; Local sub for RX handler, turn ASCII pseudo-sum into actual sum in checksum MSB
; FSR0 must be pointed at pseudo-sum MSB on entry
MOVLW 0x30
SUBWF INDF0,F,A ; Sub 30H from MSB of pseudo-sum
MOVLW .9
CPFSGT INDF0,A ; Skip if result > 9 (letter A-F)
BRA ASHa ; MS good to go, swap it
MOVLW 0x7
SUBWF INDF0,F,A ; Sub another 7 to get A-F
ASHa SWAPF POSTINC0,F,A ; Swap result to MS nibble and bump pointer to LS sum
MOVLW 0x30
SUBWF INDF0,F,A ; Sub 30H from LSB of pseudo-sum
MOVLW .9
CPFSGT INDF0,A ; Skip if result > 9 (letter A-F)
BRA ASHb ; MS good to go, swap it
MOVLW 0x7
SUBWF INDF0,F,A ; Sub another 7 to get A-F
ASHb MOVF POSTDEC0,W,A ; Fetch LS result and bump pointer back to MS
IORWF INDF0,F,A ; OR into LSnibble of result
RETURN ; Done, exit