troubles with serial communication


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2013
    Posts
    8

    Default troubles with serial communication

    hello all, I have problems with this code, do not know why it does not work,


    compiles fine without errors. I appreciate any help,


    this is the code:


    'P16f88_Tx


    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    ansel =% 00000000
    Led var PORTB.4
    Var BotonA PORTB.1


    led high
    pause 500
    led low


    transmit:
    if botona = 0 then Send 1
    led low
    goto transmit




    Send 1:
    led high
    serout PORTB.0, T1200, ["A"]
    goto transmit
    End




    'P16f88_Rx


    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    ansel =% 00000000
    VAR leda PORTB.1
    var data byte


    high leda
    pause 250
    leda low




    receive:
    PORTB.0 serin, T1200, [data]
    pause 500
    if data = "A" then one
    leda low
    goto receive


    one:
    high leda
    goto receive
    end


    regards!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    Hi,
    compiles fine without errors. I appreciate any help,
    You're got to be kidding me, does THAT code really compile without errors?
    I see at least 8 errors (that's about one error every 4th line of code) preventing it from compiling without errors, for example:
    Code:
    Var BotonA PORTB.1 - should be BotonA VAR PortB.1
    led high - should be high led
    PORTB.0 serin, T1200, [data] - should be Serin PortB.0, T1200, [data][/i]
    /Henrik.

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    643


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    Make sure you configure PORTB.0 as an output port with the TRISB register.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    compiles fine without errors.
    I saw too many errors then would not compile without too many errors.

    I fixed the reported errors until it compiled without any, but did not test your code.
    Compare them and test.
    Code:
    'P16f88_Tx
    
    
    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    ansel = %00000000
    Led var PORTB.4
    BotonA Var  PORTB.1
    
    
    high led
    pause 500
    low led
    
    
    transmit:
    if botona = 0 then Send_1
    low led
    goto transmit
    
    
    
    
    Send_1:
    high led
    serout PORTB.0, T1200, ["A"]
    goto transmit
    End
    
    '--------------------------------
    
    'P16f88_Rx
    
    
    INCLUDE "modedefs.bas"
    DEFINE OSC 4
    ansel = %00000000
    leda VAR PORTB.1
    RX_data var byte
    
    
    high leda
    pause 250
    low leda
    
    
    
    
    receive:
    serin PORTB.0, T1200, [RX_data]
    pause 500
    if RX_data = "A" then one
    low leda
    goto receive
    
    
    one:
    high leda
    goto receive
    end
    Louie

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    643


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    Also, the TRISB register should be set properly.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    In addition to Louie's correction you need to set the oscillator register and Port register. Add the following Lines of code:

    CMCOM = 7 ' comparator off

    OSCCON = %01100010 ' oscillator @ 4 MHz

    TrisB =%00000010 'for Tx device ' pin B.1 is an input all other outputs

    TrisB =%00000001 'for Rx device ' pin B.0 is an input all other outputs

    Cheers

    Al.
    Last edited by aratti; - 11th August 2013 at 10:00.
    All progress began with an idea

  7. #7
    Join Date
    Jan 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    hello, thank you very much for responding, proves and tell you how I was.
    regards!

  8. #8
    Join Date
    Jan 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: troubles with serial communication

    thank you all, sorry for so late to respond, the program I worked perfectly.
    Greetings!

Similar Threads

  1. Serial rf communication
    By tazntex in forum General
    Replies: 8
    Last Post: - 2nd August 2008, 16:27
  2. Serial Communication
    By morris in forum Serial
    Replies: 4
    Last Post: - 16th December 2006, 12:35
  3. Serial Communication
    By micah4242 in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 25th August 2006, 14:09
  4. Serial Communication
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 11th April 2006, 05:29
  5. Serial Communication
    By Keith in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th March 2005, 23:56

Members who have read this thread : 2

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