Hello.
This is my first post to this forum. I need help, please.
I have been programming PICs for a few months successfully (turn things on and off, shift out/in, display on LCD, etc). I have a project where I need to convert working BS2 SERIN code to PIC code, so I am using the SERIN2 command for the PIC.
BS2 code is SERIN 16, 16572, [DEC MAX1A]
I know this BS2 code is for 4800 baud, but I want to use 2400 for my PIC project (mode = 16780)
After MUCH trial (and error) over many days, I have NEVER been able to get SERIN2 to accept a string of numbers and place them into a WORD variable. I have tried all manner of combinations to try to get my code to receive a 5 (or fewer) ASCII numeric character string sent from my PC.
Ref: PIC16F876A at 20 Mhz
My PC waits for a "0" from the PIC, then sends the string of numbers.
MAX1A VAR WORD
mainloop:
SEROUT2 TXPin, 16780, ["0"]
SERIN2 RXPin, 16780, [DEC MAX1A]
GOSUB Display
... and do other things then go back around for more input ...
GOTO mainloop
This PIC can receive and send back BYTES to the PC (one at a time) using a BYTE sized variable in the PIC just fine, so I know the baud/word/bit/parity are set correctly.
I know my PC is sending the right characters because I use Serial Monitor software on the PC to watch it.
I see the "0" coming to the PC, then PC sends the string (like "14425" for example), but the PIC never advances beyond the SERIN2 statement. It just hangs there. Note that 14425 is still not larger than a 16-bit integer so it should fit into a WORD sized variable in the PIC. Note also that 14425 should also fit into a 14 bit word.
I have used different variable names, and even array variables without success. Still hangs.
I have even used WAIT (","), and had the PC send the "," prior to the string, but still nothing.
I have used a timeout and label sequence within SERIN2, but it just times out without "seeing" anything from the PC. I have added delays between statements without success. I've tried delays on the PC end., still no luck.
I have made the string followed by a CR,LF characters - still nothing.
There MUST be something FUNDAMENTAL that I do not understand about SERIN2 and WORD sized variables! What do I need to do so that SERIN2 fills the WORD sized variable and does not hang?
PLEASE HELP ME. My frustration level is very high.
Thanks in advance for all suggestions.
Bob Pigford
Bookmarks