Serin,Serout,Hserin,Hserout


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

    Default Serin,Serout,Hserin,Hserout

    Hi,I'm new here,
    My Englisch is not very good but i try to write some questions?Sorry.:-)

    I have a problem I want to write a code in PicBasicpro that send data to RS232.
    I use Pic16F870 PortC.6 TX and PortC.7 RX.
    Example:
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90H ' Set receive status and control
    DEFINE HSER_TXSTA 20H ' Set transmit status and control
    Define HSER_BAUD 9600

    INPUTdata VAR WORD

    START:

    PAUSE 1

    HSEROUT ["ENTER A DECIMAL NUMBER BETWEEN 0 – 65535" ,10,13]

    But the problem is I become on other software in Visual Basic on the PC this string:…Žิ…’ ม`ฤลƒ‰อมŒ ฮ•ย…’ ย…ิื……ฮ`p `v5us5
    and another example is when i want from pc to send data to pic and back i receive just a one character .
    I send Tony end come back to PC just T.
    Example:
    loop:
    Serin PORTC.7, T2400, ReadIn
    Serout PORTC.6,T2400,[ReadIn,10,13]
    goto loop

    I have search in internet and in PicBasicPro handbook but is no good explanation.

    Thanks pesticida

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You should have a MAX232 between PIC and PC. Do you?

    OR use SERIN/SEROUT in inverted mode... N2400 could work.

    Also i've notice you use HSERIN/HSEROUT to acheive a 9600 Baud comm... by using your setting the error % will be about 7% wich is really bad.

    If you change your settings to
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h ' Set receive status and control
    DEFINE HSER_TXSTA 24h ' Set transmit status and control + BRGH=1
    Define HSER_BAUD 9600

    this will gives you an error % of 0.16%... far better
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I send Tony end come back to PC just T.
    Example:
    loop:
    Serin PORTC.7, T2400, ReadIn
    Serout PORTC.6,T2400,[ReadIn,10,13]
    goto loop
    Tony consists of 4 bytes. You would need to receive then send 4 bytes.

    Serin PORTC.7, T2400, Char1, Char2, Char3, Char4
    Serout PORTC.6,T2400,[Char1, Char2, Char3, Char4,10,13]

    Or use Serin2/Serout2 with the STR modifier.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi all,
    Thanks for the answers,Yes I have Max232,I have just try Hserout ["my text"] and this work good .I dont know why :-).
    I think I must learn more about RS232 and all the little details like baud rate, inverted or not inverted :-(.


    Thanks!!!
    Regard Pesti
    Last edited by Pesticida; - 28th June 2005 at 09:28.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I have use now :
    DEFINE HSER_TXSTA 24h ' Set transmit status and control + BRGH=1
    Define HSER_BAUD 9600

    and all work very good thanks, you are the bests !

    Regard Pesti.

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