PDA

View Full Version : USART Problem Receiving Bytes



CocaColaKid
- 15th September 2005, 16:55
main:
if RCIF = 1 then ' If RCIF=1 there's a new character in RCREG
BytesIn[ByteCnt] = RCREG ' Yes. Then store it in array
if BytesIn[ByteCnt] = eom then OutMsg
ByteCnt = ByteCnt + 1 ' Increment array index pointer
endif
goto Main


This code works great but how can I send the value 23? If I try it assumes each character is a byte when they are not.

mister_e
- 15th September 2005, 17:05
not sure of me but what about


HSERIN [str BytesIn\ByteInArraySize\eom]

CocaColaKid
- 15th September 2005, 17:46
I think part of my problem lies in the fact that I'm using the Serial Communicator in MCSP. I think anything you enter in the transmit window is by default send as ascii. However if this in in fact the case then I have no way to send 23 since the ascii representation of 23 is "end of transmission block".

mister_e
- 15th September 2005, 17:49
This may help



Parse Control Characters

When enabled, the parse control characters option enables you to send control characters in your message, using either a decimal or hexadecimal notation. For example, if you want to send hello world followed by a carriage return and line feed character, you would use hello world#13#10 for decimal, or hello world$D$A for hex. Only numbers in the range 0 to 255 will be converted. For example, sending the message letter #9712345 will be interpreted as letter a12345.

If the sequence of characters does not form a legal number, the sequence is interpreted as normal characters. For example, hello world#here I am. If you don't want characters to be interpreted as a control sequence, but rather send it as normal characters, then all you need to do is use the tilda symbol (~). For example, letter ~#9712345 would be sent as letter #9712345.

CocaColaKid
- 15th September 2005, 17:50
I was just going to post that. Thanks.