pic18f4520 baud rate change to 115200


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    115Kbaud with a 4MHz XTAL is tough. Because the divisor has to be an integer, you can get only within 3.55% of the exact baud rate. That error is probably a bit too much. Look at the datasheet table 18-3.

    20Mhz works much better. That gives you a 1.36% error. Small enough to work well.
    In this case, set BRGH = 1 and SPBRG = 10
    what about 16Mhz XTAL

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


    Did you find this post helpful? Yes | No

    Default

    With 16 MHz the best error Percentage you'll get will be -0.79% witch is usually fair enough.

    This assume you're aware that you MUST use the 16 bit baudrate generator for that.

    Now to set it in C... it's your problem In PicBasic Pro
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 34  ' 115200 Baud @ 16MHz, -0.79%
    SPBRGH = 0
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    My PicMultiCalc should help you a little bit
    http://www.mister-e.org/pages/utilitiespag.html
    Last edited by mister_e; - 30th September 2007 at 08:44.
    Steve

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

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. Replies: 14
    Last Post: - 20th March 2008, 13:54
  3. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  4. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 22:41
  5. Baud Rate and Timing Calculator
    By picnaut in forum General
    Replies: 3
    Last Post: - 23rd January 2004, 16:48

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