Serial Receive issue

2013-02-11
2013-05-30
  • I am sending and receiving serial data at 9600 baud using the PICkit 2 UART tool.
    I can get the message "GCBASIC RS232 Test" to appear just fine.
    I'm sending back a 1 or 2 (hex 31 and hex 32) to control an LED.
    The echo comfirms the PICkit 2 is sending 31 hex and 32 hex but the GCB SerReceive is getting a 71hex and 72 hex.
    It's add an extra leading bit (110001 shows up as 1110001).

    Any idea why its adding this bit?

    'Serial settings
    #define SerInPort PORTB.6
    #define SerOutPort PORTB.7
    #define SendAHigh Set SerOutPort off
    #define SendALow Set SerOutPort on
    #define RecAHigh SerInPort off
    #define RecALow SerInPort on

    'Set pin directions
    Dir SerOutPort Out
    Dir SerInPort In

    InitSer 1, r9600, 1+WaitForStart, 8, 1, none, invert
    Do
        SerPrint 1, "GCBASIC RS232 Test"
    SerSend 1, 13
    SerSend 1, 10
    Wait 1 s
    SerReceive 1, Temp
    SerSend 1, Temp
    SerSend 1, 13
    SerSend 1, 10
        If Temp = "q" Then Set PORTB.5 on
        If Temp = "r" Then Set PORTB.5 Off

    Loop