Baud Rate and Timing Calculator


Closed Thread
Results 1 to 4 of 4
  1. #1

    Thumbs up Baud Rate and Timing Calculator

    Hello Everyone,

    Fred Hillhouse has made a great baud rate and timing calculator using Microsoft Excel. He's been kind enough to email it to me and let me post it for everyone.

    Basically, in the Excel spreadsheet you have 3 light blue boxes where you enter in numerical values; one for your oscillator frequency, one for your desired baud rate, and one for your desired timer interrupt frequency (to calculate timer interrupts).
    If you only want to do a baud rate calculation, ignore the "Desired Frequency" box. If you only want to do a timer interrupt calculation, ignore the "Baud rate, desired" box.

    These values are all tied into tables, with the main calculations hilighted in green. If you change anything in the light blue boxes the data in the tables will change.

    I have only used the baud rate portion of the calculator so far, but if Fred has put as much time into the timer portion, I'm sure that it will work great too.

    So, if you want to change your PIC's baud rate programmatically (i.e. without using DEFINE), you simply use the following code.


    RCSTA = $90 ' Enable USART receive


    TXSTA = $20 ' Set USART parameters if BRGH = 0

    OR

    TXSTA = $24 'Set USART parameters if BRGH = 1


    SPBRG = ??? ' Whatever the SPBRG value is on the calculator


    That's it!

    Those 3 lines (remember to choose only one correct value for TXSTA) are all you need to change your baud rate in code and use HSERIN and HSEROUT at the baud rate you've set.

    I've used this calculator for all the standard baud rates from 300 to 115200 and it works great. It even calculates your percentage of error using certain crystals at different baud rates.
    Just remember, with a 20MHz oscillator, you're not going to be able to run the USART any lower than 2400 baud. However, a 4MHz oscillator can run the entire range from 300 baud to 115200 baud.

    Enjoy.
    Attached Files Attached Files
    ---> picnaut

  2. #2
    Fred's Avatar
    Fred Guest


    Did you find this post helpful? Yes | No

    Default

    Be careful using the TIMER0 stuff. I haven't done much testing of it.

    Let me know if you have any problems with the file.

  3. #3
    bobthebud's Avatar
    bobthebud Guest


    Did you find this post helpful? Yes | No

    Cool

    Nice one my friend. On behalf of us all -- Thanks!

  4. #4


    Did you find this post helpful? Yes | No

    Talking

    Don't forget about Fred.
    He did all the work.
    I just posted it.
    I'm thinking of making a slick VB version of the calculator at some point.
    I'll post it when I do.
    ---> picnaut

Similar Threads

  1. Serial and interrupt
    By test153 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 8th February 2009, 14:02
  2. pulsout pulsin on same pin - timing?
    By vacpress in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th January 2009, 07:21
  3. timing for dmx??
    By oscar in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th May 2005, 17:22
  4. Need help, high speed D/A converter, see code
    By rpatel in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th December 2004, 01:33

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