Problem on sending data on serial port


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Posts
    37

    Default Problem on sending data on serial port

    hellow everyone,

    i want to send a number of words (strings) to a serial port, but when simulating the design on proteus isis,the virtual terminal to display the strings (words) of the serial port,displays words (strings) which i did not send...any help please..
    code:
    Code:
    define OSC 20
    trisb=$F8 
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    main:
    portb=0
    if portb.3=1 then
    HSEROUT ["door" ,10,13]
    pause 200
    HSEROUT ["opened" ,10,13,10,13]
    pause 200
    endif
    goto main
    end
    simulation attached:
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Problem on sending data on serial port

    I would start by checking the baud rate. this line:
    Code:
    DEFINE HSER_SPBRG 25
    is the same as I use with a 48mHz OSC. Now mind you, I am just starting to get into serial so I may be way off here.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default Re: Problem on sending data on serial port

    Place a MAX 232 between your pic and the terminal, in your simulation, and you will receive the carrect characters.

    Terminal is expecting an inverted signal (what max 232 will do, along with the level translation) and since it doesn't receive the proper signal isn't able to decode what you send.

    Cheers

    Al.
    All progress began with an idea

  4. #4
    Join Date
    Feb 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Problem on sending data on serial port

    Quote Originally Posted by cncmachineguy View Post
    I would start by checking the baud rate. this line:
    Code:
    DEFINE HSER_SPBRG 25
    is the same as I use with a 48mHz OSC. Now mind you, I am just starting to get into serial so I may be way off here.
    i've not understand you above,but i modified the code and tried to simulate it again,the results on the terminal is not what i sent.....
    code:
    Code:
    define osc 20
    char var byte
    trisb=1
    trisc=0
    RCSTA=$90
    TXSTA=$24
    SPBRG=25
    start:
    hserin 1000,mainloop,[char]
    mainloop:
    if portb.3=1 then
    hserout ["door is opened",13,10]
    hserout [char]
    endif
    goto start
    end
    Is there another way to send data to serial port...?an example will do...

    simulation results attached.
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Problem on sending data on serial port

    Look at the SEROUT2 command in the manual.
    Dave
    Always wear safety glasses while programming.

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