16F18446 - setting baudrate for HW EUSART


+ Reply to Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: 16F18446 - setting baudrate for HW EUSART

    when you get a result like
    DEFINE HSER_SPBRG 832 you realize something is very wrong since an 8 bit register can not accept that value ever

    you have enabled the 16 bit baud rate generator in every case


    BAUDCON.3 = 1 'Enable 16 bit baudrate generator

    for 19200
    SP1BRGL = 160:SP1BRGH = 1

    for 9600
    SP1BRGL = 64:SP1BRGH = 3


    BAUDCON.3 = 0 '8 bit baudrate generator
    for 9600
    SP1BRGH = 51

    for 19200
    SP1BRGH = 25
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: 16F18446 - setting baudrate for HW EUSART

    its probably better to say

    there are two baudrate clock source dividers brgh=0 ; fosc/64 and brgh=1 ; fosc/16 and
    and you have the choice of 8 or 16 bit baud rate generators, so 4 options for every baud rate


    BAUDCON.3 = 1 'Enable 16 bit baudrate generator
    brgh=1
    for 19200
    SP1BRGL = 160:SP1BRGH = 1

    for 9600
    SP1BRGL = 64:SP1BRGH = 3

    brgh=0
    for 19200
    SP1BRGL = 103:SP1BRGH =0


    for 9600
    SP1BRGL = 207:SP1BRGH = 0





    BAUDCON.3 = 0 '8 bit baudrate generator
    brgh=1
    for 9600
    SP1BRG = 207


    for 19200
    SP1BRG = 103

    brgh=0
    for 9600
    SP1BRG = 51

    for 19200
    SP1BRG = 25
    Warning I'm not a teacher

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default 16F18446 - setting baudrate for HW EUSART

    Thanks a lot Richard.

    All your settings work like a charm

    Still a question: why would one choose the 8 bit baudrate generator - seems less accurate, no?
    Last edited by flotulopex; - 15th December 2025 at 17:35.
    Roger

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: 16F18446 - setting baudrate for HW EUSART

    why would one choose the 8 bit baudrate generator - seems less accurate, no?

    in reality accuracy is not always critically important, 1% or larger errors still work well in 90% of cases for tty serial transmission.
    8bit generator results can be equally accurate anyway.
    if you want to switch between rates rapidly a 8bit change is twice as quick to implement as a 16 bit one
    Warning I'm not a teacher

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default 16F18446 - setting baudrate for HW EUSART

    Thanks, Richard
    Roger

Similar Threads

  1. 16F18446 - limit program memory size for burning time saving
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 22nd December 2024, 22:44
  2. 16F18446 - maybe missing some registers settings
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th December 2024, 18:43
  3. Blinker for 16F18446 - OSC settings and PORT addressing
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th February 2024, 14:40
  4. HSER baudrate
    By pedja089 in forum Serial
    Replies: 14
    Last Post: - 7th August 2011, 20:46
  5. different baudrate
    By danial in forum Serial
    Replies: 3
    Last Post: - 2nd February 2010, 12:37

Members who have read this thread : 12

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