How to upon receiving data via RS232, MCU immediately sends it back to the sender?


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71

    Default How to upon receiving data via RS232, MCU immediately sends it back to the sender?

    I want to make something like this,when I receiv data from RS232 immediatelu send back to the sender,i write code but It can't compile it.Why?
    define OSC 8
    INCLUDE "Modedefs.bas"
    TRISA = %00000100
    TRISB = %00000000
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    Primi var BYTE
    Prati var Byte
    Isprati var BYTE

    Main:
    PORTA = $00
    SERIN PORTA.3,N2400,Primi
    pause 3000
    IF Primi <> 0 Then Prati
    ENDIF
    Goto Main


    Prati:
    Primi = Isprati
    Serout PORTA.2,N2400,Isprati
    Goto Main


    END

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: How to upon receiving data via RS232, MCU immediately sends it back to the send

    Remove the ENDIF and add the square parentesis it will compile.

    Main:
    PORTA = $00
    SERIN PORTA.3,N2400,Primi
    pause 3000
    IF Primi <> 0 Then Prati
    Goto Main


    Prati:
    Primi = Isprati
    Serout PORTA.2,N2400,[Isprati]
    Goto Main

    Cheers

    Al.
    Last edited by aratti; - 21st February 2011 at 21:12.
    All progress began with an idea

  3. #3
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: How to upon receiving data via RS232, MCU immediately sends it back to the send

    no,it's not working

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: How to upon receiving data via RS232, MCU immediately sends it back to the send

    Did you turn portA digital ? Remember that by default portA is set as analog, so you cannot use the serin/serout command.

    Which pic are using?

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: How to upon receiving data via RS232, MCU immediately sends it back to the send

    No I forget to turn into digital,I have to use ADCON = 7?
    I am using PIC16F877,but IF it's working I will make a small network,so I should send a messages from one PC to onether with RS232 protocol.

  6. #6
    Join Date
    Jun 2005
    Location
    Surrey, England
    Posts
    35


    Did you find this post helpful? Yes | No

    Default Re: How to upon receiving data via RS232, MCU immediately sends it back to the send

    Another error: you define Prati as a byte then use it as a label - remove the byte definition. Also you assign the output value to Isprati which is undefined
    Peter

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