I see no reference to filling an array and waiting for termination characters in the PBP manual. Do you have a sample?
Thanks,
Bob Hiller
Lifts for the Disabled LLC
I think he meant ...
See HSERIN in the PBP manual. Look at the STR modifier.
<br>
DT
Being a beginner myself I have the same problem with getting simple commands and mondifiers to function. I'm looking in the PBP manual at the STR Modifier and they just don't give any examples on how to use it. I'm also interested in the use of this function as I would like to be able to send commands to the PIC and dinamicly update it.
MyVars VAR BYTE(8)
Main:
HSERIN 500,NoData,[STR MyVars\8\"~"]
NoData:
do something else
This will wait 500mS before jumping to NoData. It will receive a string of up to 8 characters
in byte array MyVars, or exit on receipt of the "~" character.
From a PC I send 123:CRLF as 495051581310
When I try:
MyVars VAR BYTE(8)
Main:
HSERIN 500,NoData,[STR MyVars\6\":"]
goto main
NoData:
HSEROUT ["Timeout",$0d,$0a]
Goto main
It always goes to NoData. I never get anything into MyVars.
If I use HSERIN 500,NoData,[STR MyVars\1\":"] I get random data. It is different each time I send the data.
What am I missing?
Thanks,
Bob Hiller
Lifts for the Disabled LLC
Have you tried increasing the timeout period?
P.S. How do you know what you're receiving? Your example doesn't show how you're
checking what's received!
Don't send 123:CRLF as 495051581310....send it as 123:<CR> with line feeds turned on at the PC.
HSERIN doesn't need to use raw hex codes for the data (i.e. sending 10 for a line feed, etc).
Are you using the internal oscillator on the PIC?
The internal oscillator isn't always accurate. Could cause your baud rate to be off by just enough to confuse everything.
Are you using a MAX232 type device between the PIC and the PC?
The hardware UART uses 'TTL-RS232', commonly called 'Normal' in PBP circles. Try using SERIN2/SEROUT2 and using an inverted mode if you don't have a MAX232.
Are you sure the PIC is configured correctly for the desired baud rate?
Can get a bit confusing with all of the options a PIC has. Double check them...
Are you sure the config registers/any other registers are set up correctly?
Internal vs. External crystals...and so on and so on...
Bookmarks