I'm having a problem and it's driving me bonkers! I have a very simple QuickBasic program running on my laptop:
' Open communication channel to COM1 at 9600 Baud.
OPEN "com1:9600,n,8,1,cd0,cs0,ds0" FOR OUTPUT AS #1
'---- Default Settings ----
byte = 85 ' BIN %01010101
'---- Body ----
MainLoop:
INPUT "Just hit RET.", CHAR$
PRINT #1, byte;
GOTO MainLoop:
The program is supposed to send decimal-85 out of the COM1 port every time I hit return. OK, fine. It seems to work, and yes, I know I'm not closing the COM port.
The PIC is running the following program:
include "modedefs.bas" ' PIC is 16F84A
Sdata VAR PORTA.4 'serial input on pin RA4
CHAR VAR BYTE
TRISA = %00010111 ' set PORTA pins RA0-RA2, and RA4 to INPUT
TRISB = %00000000 ' set PORTB pins to output
PORTB = %00000000 ' Clear port B
main:
serin Sdata, N9600, char ' input byte
PORTB = CHAR
goto main
OK, that looks pretty straightforward, too! The problem is, the PIC thinks it's receiving decimal-32 (ASCII character for a space). Huh?? Can anyone explain why I'm getting decimal-32? I presume that the PC is sending 85 first, and 32 second, but I sure don't see how or why!
Jeff
Bookmarks