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


Closed Thread
Results 1 to 8 of 8
  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

  7. #7
    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,I changed everything,but stil nothing.
    I think the problem is in the MCS.When I compile code for PIC18F2550
    there is an error.
    And I want to make the code from DT,code for the Baragraphs it can't
    compile it.

  8. #8
    Join Date
    Dec 2010
    Location
    Colchester England
    Posts
    20


    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

    I see from your code that you do not assign a value to Isparti.

    Code:
    Prati:
    Primi = Isprati
    Serout PORTA.2,N2400,[Isprati]
    Goto Main
    You assign Primi with the value IspartI, would it be better to reverse it ?.

    Isparti = Primi

Members who have read this thread : 1

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