hserout not working with parity


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    When I use Mister E's Pic Multi Calc, it gives me these settings for hser at that baud rate:

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 77 ' 38400 Baud @ 48MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

  2. #2
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Correct since you are using BRG16=0. Note that mine is BRG16=1.

    But my problem is not the bps, it is the parity. It all works fine without parity.

    Anyone else can help?

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I remember this problem.
    Took me awhile to find it again ...

    http://www.picbasic.co.uk/forum/show...72&postcount=2

    hth,
    DT

  4. #4
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Question

    Hi Darrel,
    i already use

    DEFINE HSER_EVEN 1
    DEFINE HSER_BITS 9


    but in hyperterminal it shows garbage. I set hyperterminal to 8 data bit, even parity, 1 stop bit.

    If i dont use the above 2 defines and set hyperterminal to 8data bit, no parity, 1 stop bit, no problem.

    Is this a bug with PIC18f4550?

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    What I was trying to say in the other thread was ...

    If you want 9 total bits (8 data + 1 parity) then the USART must be set for 9-bit operations.
    That is done by setting TX9 (TXSTA.6) and RX9 (RCSTA.6) bits.

    With your current settings, that would be ...

    DEFINE HSER_RCSTA 0D0h
    DEFINE HSER_TXSTA 64h


    However, PBP will do that for you, if you let it.
    But when you use these defines ...
    Code:
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 24H 'HIGH SPEED MODE BAUD RATE GENERATOR
    then you have specified what TXSTA and RCSTA values should be, and that overrides anything PBP will do.
    And 9-bit will not be enabled.

    If you don't define TXSTA and RCSTA, then PBP will do it for you, and all you have to tell it is the baud rate, total bits and parity.
    In your case ...
    Code:
    DEFINE OSC 48 ; set oscilator speed to 48mHz 
    DEFINE HSER_BAUD  38400
    DEFINE HSER_BITS 9
    DEFINE HSER_EVEN 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically
    hth,
    Last edited by Darrel Taylor; - 24th March 2010 at 09:41.
    DT

  6. #6
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Thumbs up

    Ok, thanks Darrel. It works now.

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