Data corrupterd when using serout command


Closed Thread
Results 1 to 12 of 12
  1. #1
    johnson's Avatar
    johnson Guest

    Default Data corrupterd when using serout command

    dear all,

    I have some problems dealing with interfacing between pic16f628a and pc's hyper-terminal. My code is as follow:




    INCLUDE "modedefs.bas"
    testvalue var byte
    pause 3000

    '
    'other code
    '
    '

    SEROUT PORTB.2,T2400,["hello"] 'sending the string "hello"
    SEROUT PORTB.2,T2400,["123"]
    SEROUT PORTB.2,T2400,["abc"]

    main:
    serin PORTB.1,T2400,testvalue 'waiting for 1 byte of data and store it
    'in testvalue
    SEROUT PORTB.2,T2400,[testvalue]
    goto main



    Whenever I power up my PIC, the 1st byte of data sent will be corrupted(which shown in hyper terminal), however the rest of the data are correct. I wonder why??? Anyone got solution???

    ps: i'm using pic16f628's, tx and rx is connected to hin232




    thanks,

    cheer:>

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    There's a whole heap of reasons...

    Try this...

    Loop:
    SEROUT PORTB.2,T2400,[REP $00\8,"hello "] 'sending the string "hello"
    SEROUT PORTB.2,T2400,["123 "]
    SEROUT PORTB.2,T2400,["abc",13,10]
    Pause 1000
    Goto Loop

    Have you now got clean transmission?

    Those NULS $00 sent at the start are there to push any line garbage lurking in your comms link away. Also, if you're not using a Resonator or Crystal oscillator, then 2400 baud can produce significant errors - especially at start up, and it can take a few bits for the PC's USART to sync-up if it's right at the edge of timing tollerance.

    Melanie

  3. #3
    johnson's Avatar
    johnson Guest


    Did you find this post helpful? Yes | No

    Cool

    thanks man, I am trying the way as u stated :>

  4. #4
    johnson's Avatar
    johnson Guest


    Did you find this post helpful? Yes | No

    Default

    hi i got some doubt:

    what is the syntax "$00\8" means? I got compilation error "error line 6: expected "]", where line 6 is:

    SEROUT PORTB.2,T2400,[$00\8,"hello "] 'sending the string "hello"


    help please,


    thanks,

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Sorry, my omission of the word REP... I've corrected it.

  6. #6
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Question

    What does REP do?
    Is this in the manual?

    Toni

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    REP c\n

    Repeat character c, n times...

    In the manual in at least four places... DEBUG, LCDOUT, SEROUT, SEROUT2... and in list of Reserved Words.

  8. #8
    TONIGALEA's Avatar
    TONIGALEA Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for pointing that out.

  9. #9
    L_Gaminde's Avatar
    L_Gaminde Guest


    Did you find this post helpful? Yes | No

    Default

    This is something that used to come up a lot
    just before your pause 3000 put in

    high portb.2

    you could even change the pause 3000 to

    pause 500

    this should take care of all your problems

    Is there a spell checker for this forum ??

  10. #10
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    As there are more and more questions regarding serial comunication we should put some "How To's" together and post it in the FAQ category.

    There appears to be a lot of confusion about the different modes (TRUE/INVERTED), Baud rate vs. clock speed etc.

    regards

    Ralph
    Last edited by NavMicroSystems; - 14th August 2004 at 02:16.

  11. #11
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Yup, I agree. It's a question of finding time to do it all... nothing stopping other folks contributing to the FAQ... however Serial Comms is a major subject, and not something that gets covered in a couple of paragraphs and ten lines of code. Just for starters, you can do comms between two PICs a dozen different ways, and them some... it's one of those subjects that has so many variables, that what works brilliantly for one application, ends up totally inappropriate for another.

  12. #12
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    If there is some FTP-space on the server we could start writing a "HowTo" and share that Document using FTP.

    Once we think it covers everything it will go to the FAQ section as PDF.

    regards

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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