SEROUT being unreliable


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default SEROUT being unreliable

    Hi,

    I'm having a problem with SEROUT. When I use HSEROUT it works perfectly, but when I use SEROUT or SEROUT2 I get errors in the data. I'd guess that about 5% of the characters are corrupted.

    PIC: 18F4550
    Clock: 48Mhz

    HSEROUT code (works):
    Code:
    DEFINE HSER_TXSTA  24h
    DEFINE HSER_RCSTA  90h
    DEFINE HSER_BAUD   2400
    DEFINE HSER_SPBRG  25
    DEFINE HSER_BITS   8
    
    HSEROUT ["This is a test."]
    SEROUT code (5% of characters are corrupted):
    Code:
    SEROUT PORTB.3,0,["This is a test."]
    Does anyone have any ideas as to why this would be happening?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    I'm having a problem with SEROUT. When I use HSEROUT it works perfectly, but when I use SEROUT or SEROUT2 I get errors in the data. I'd guess that about 5% of the characters are corrupted.
    PIC: 18F4550
    Clock: 48Mhz
    Does anyone have any ideas as to why this would be happening?
    Cable straight from PIC to PC?
    DEFINE OSC 48 used?
    Do higher/slower baud rates work better/worse?

  3. #3


    Did you find this post helpful? Yes | No

    Default

    HSERIN and HSEROUT use the built in UART of some PIC parts to communicate. SERIN(2) and SEROUT(2) I believe are software emulations of a UART. At the clock speed you are running at I would probably be better to use the UART. The software emulation uses up too much of the PIC resources anyway.

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Its a cable going directly to a DoubleTalk text-to-speech board.

    I am defining OSC 48 yes.

    I initially started at 9600 baud, and lowered to 2400 to see if that would fix it, which it didn't.

    When i use SEROUT or SEROUT2 the corrupted characters cause the text-to-speech to mispronounce the words. HSEROUT is flawless. No issues at all.

    The reason I need this is I need at least 2 serial outputs and this PIC only has 1 hardware USART.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    The reason I need this is I need at least 2 serial outputs and this PIC only has 1 hardware USART.
    Semi-silly idea for you...but might be easier than you think. Might even be able to write a macro to handle the switching for you...
    Use the HSEROUT for your serial out as you've already planned it out...
    Get your hands on a couple of AND gates, or whatever works...
    Use another PIC pin or two as STEERING LOGIC.

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Semi-silly idea for you...but might be easier than you think. Might even be able to write a macro to handle the switching for you...
    Use the HSEROUT for your serial out as you've already planned it out...
    Get your hands on a couple of AND gates, or whatever works...
    Use another PIC pin or two as STEERING LOGIC.
    Thats a pretty good idea.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    Thats a pretty good idea.
    Well, heck, glad I could help...
    Generally I'm useless
    Does your program have any interrupts running in it?

  8. #8
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Actually, i do have 3 interrupts in this program. Maybe SEROUT is getting interrupted and thats messing with the data.

    I'm gonna try disabling the interrupts while I run SEROUT... Not the best long term solution as It wouldnt be good to miss one of those interrupt events, but its worth a try to see if thats whats causing my problem.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  9. #9
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I just lowered the SEROUT2 baud to 600 and it works by the look of it. But that is much too slow and it holds up my program.

    With a 48Mhz clock, i'm not sure why it would struggle with 9600 baud, let alone 2400.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  10. #10
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    With the Double-Talk chipset you can pre-record your audio, and just send the address for the phrase that you want to play. You might be able to send out the bytes between interrupts. If I remember correctly, (I don't have my book with me here,) you have to end the play address with a 13, and the chipset will play whatever is stored at that address as soon as it sees the 13. This way you would only need to send out a few bytes each time.

    Jerry.
    If your oscilloscope costs more than your car...

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

Members who have read this thread : 0

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