Simple Serial Comms.


Closed Thread
Results 1 to 2 of 2
  1. #1

    Default Simple Serial Comms.

    Good day Picers.

    I am sending serial data from one pic to another using two 433Mhz RF Modules.
    On the receiver side, I send some data (for debug purposes) to my PC.

    My Transmitter Code:
    <hr>
    <code>
    '************************************************* ***************
    '* Name : Transmit.bas *
    '************************************************* ***************

    Include "modedefs.bas"

    DEFINE OSC 4 ' Set the Xtal frequency
    SerialOutPin VAR PORTC.2 ' Serial Out
    LEDPin Var PORTC.3
    DEFINE CHAR_PACING 1000

    ADCON1 = 7
    TRISC = %00000000 ' SET ALL PORT C TO OUTPUTS

    Main:
    &nbsp;&nbsp;PAUSE 5000
    &nbsp;&nbsp;
    &nbsp;&nbsp;serout2 SerialOutPin, 16780, [#1,#2,#3,#4,#5]
    &nbsp;&nbsp;Pause 1000
    &nbsp;&nbsp;HIGH LEDPin
    &nbsp;&nbsp;Pause 1000
    &nbsp;&nbsp;LOW LEDPin
    &nbsp;&nbsp;PAUSE 1000
    &nbsp;&nbsp;Goto Main
    &nbsp;
    END
    </code>
    <hr>

    My Receiver Code :
    <hr>
    <code>
    '************************************************* ***************
    '* Name : Receiver.bas *
    '************************************************* ***************

    Include "modedefs.bas"

    DEFINE OSC 4 ' Set the Xtal frequency
    SerialInPin VAR PORTC.2 ' Serial Out
    SerialOutPin VAR PORTB.7
    LEDPin Var PORTC.3
    CDPin VAR PORTD.2
    CDPinState VAR Byte
    DataReceived var byte[5]
    I VAR BYTE
    iLoopPin var byte
    Data_ArrayCount var byte
    ADCON1 = 7

    Main:
    Pause 5000
    high LEDPin

    Loop:
    &nbsp;&nbsp;for Data_ArrayCount = 0 to 4
    &nbsp;&nbsp;&nbsp;&nbsp;DataReceived[Data_ArrayCount] = 0
    &nbsp;&nbsp;next Data_ArrayCount
    &nbsp;&nbsp;
    &nbsp;&nbsp;SERIN2 SerialInPin,396, 4000, SerialTimeout, [str DataReceived\5]
    &nbsp;&nbsp;
    &nbsp;&nbsp;if (DataReceived[0] = 1 and DataReceived[1] = 2 and DataReceived[2] = 3) then
    &nbsp;&nbsp;&nbsp;&nbsp;serout2 SerialOutPin, 16780, ["DATA=======", 13, 10]
    &nbsp;&nbsp;else
    &nbsp;&nbsp;&nbsp;&nbsp;serout2 SerialOutPin, 16780, ["JUNK:", #DataReceived[0], ":", #DataReceived[1], ":", #DataReceived[2],13,10]
    &nbsp;&nbsp;endif
    Goto LOOP

    SerialTimeout:
    &nbsp;&nbsp;serout2 SerialOutPin, 16780, ["TIMEOUT", 13, 10]
    Goto LOOP
    &nbsp;&nbsp;
    END
    </code>
    <hr>


    On the PC Side I get the following:
    <hr>
    JUNK:103:216:131
    TIMEOUT
    JUNK:103:216:131
    TIMEOUT
    JUNK:103:216:131
    TIMEOUT
    JUNK:103:216:131
    TIMEOUT
    JUNK:103:216:131
    <hr>

    Any idea what I'm doing wrong?

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Oops!

    I see I have different baud rates on serin2 and serout2.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serial Comms through TX/RX pair jumbled
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th July 2009, 21:04
  3. Some comments on serial comms please.
    By muddy0409 in forum Schematics
    Replies: 1
    Last Post: - 15th June 2007, 09:53
  4. Replies: 2
    Last Post: - 23rd July 2006, 08:16
  5. Simple serial debug script
    By barkerben in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th November 2005, 16:12

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts