• AVR Freaks

Revised SPBRG Calc...

Author
K8LH
Super Member
  • Total Posts : 1887
  • Reward points : 0
  • Joined: 2004/03/26 05:12:34
  • Location: Michigan, USA
  • Status: offline
2005/02/14 21:30:42 (permalink)
0

Revised SPBRG Calc...

For those who may be interested, I have revised the Excel 2000 SPBRG Calculator spreadsheet to support the 16 bit SPBRG modes available on some newer devices, like the16F690 and 18F2620 (and others)...

8-bit SPBRG Solutions
Enter '0' (zero) in the BRG16 cell and enter '0' or '1' in the BRGH cell to produce standard 8 bit SPBRG solutions for our legacy UART PIC devices or 8-bit SPBRG compatible mode solutions for the newer 16-bit capable devices...

16-bit SPBRG Solutions
Enter '1' in the BRG16 cell and enter '0' or '1' in the BRGH cell to produce the new 16 bit SPBRG solutions... A 16-bit SPBRG solution cannot be used on legacy 8-bit SPBRG PIC devices...

You can also edit the "Display errors less than" cell, oscillator frequency cells, and any of the Baud Rate cells in the left most column...

I know, I know... You're supposed to use the formulas but I still find it easier to look at a much wider selection of baud rates and "plug in" different crystal frequencies and change BRGH modes to see the results at-a-glance...

You'll probably notice the precision of the new 16 bit SPBRG modes is awesome...

Regards, Mike



(288)
post edited by K8LH - 2007/02/23 14:25:05
#1

16 Replies Related Threads

    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Revised SPBRG Calc... 2005/02/15 03:32:41 (permalink)
    0
    Thanks for inserting the exact multiply crystal values... so that people will see that such things exist.

    aspforum.mchp.guest
    #2
    FredH
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2003/11/12 14:02:28
    • Status: offline
    RE: Revised SPBRG Calc... 2005/02/15 06:53:03 (permalink)
    0
    Greetings Mike,


    Here is my rendition. I have been using it over the last several years. I have been modifying it just about every time I use a PIC.

    Best regards,
    Fred
    #3
    zalex
    Super Member
    • Total Posts : 702
    • Reward points : 0
    • Joined: 2004/10/14 02:00:40
    • Location: UK
    • Status: offline
    RE: Revised SPBRG Calc... 2006/01/18 06:21:42 (permalink)
    0
    What about the PIC18F4550, where the CPU frequency can be 48MHz ?

    Alex
    #4
    K8LH
    Super Member
    • Total Posts : 1887
    • Reward points : 0
    • Joined: 2004/03/26 05:12:34
    • Location: Michigan, USA
    • Status: offline
    RE: Revised SPBRG Calc... 2006/08/02 16:29:50 (permalink)
    +2 (1)
    Hi guys,

    I've come up with a single file stand-alone SPBRG Calculator application to share (pictured below).  It's about 1-MByte in size.

    Download here --> K8LH SPBRG Calculator v11.exe     (the attachment below is only the graphic)

    Simply enter your oscillator frequency in the Fosc field, press <enter>, and toggle the BRGH and BRG16 radio buttons.  Only SPBRG solutions with less than 4% bit rate error are displayed.  The Code Generator portion of the program is not implemented at this time.

    Regards, Mike


    post edited by K8LH - 2010/04/23 06:20:03

    Attached Image(s)

    #5
    potholer
    Super Member
    • Total Posts : 434
    • Reward points : 0
    • Joined: 2005/02/13 07:41:10
    • Status: offline
    RE: Revised SPBRG Calc... 2006/08/02 16:39:16 (permalink)
    0
    How many downloads do you anticipate?
    I have a fair amount of bandwidth on my current web-hosting bundle, the large majority of which I don't currently use. If you don't expect multiple thousands of downloads/month, email me.
    post edited by potholer - 2006/08/02 16:55:47
    #6
    ric
    Super Member
    • Total Posts : 29870
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    RE: Revised SPBRG Calc... 2006/08/02 16:49:09 (permalink)
    0
    You just beat me potholer. Smile
    I've also got plenty of spare bandwidth. buzz me if potholer's offer falls through wink

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    K8LH
    Super Member
    • Total Posts : 1887
    • Reward points : 0
    • Joined: 2004/03/26 05:12:34
    • Location: Michigan, USA
    • Status: offline
    RE: Revised SPBRG Calc... 2006/08/03 05:22:37 (permalink)
    0
    Thank you both for your kind offer.  I've found space to host the file and have modified the post above with the link.  Please check it out.

    Regards, Mike
    #8
    Guest
    Super Member
    • Total Posts : 80503
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Revised SPBRG Calc... 2006/08/03 09:54:55 (permalink)
    0
    Very nice job on the program and sheet! I've linked to those from my site.
     
    http://www.piclist.com/techref/microchip/spbrgcalc.asp may also be of use for 8 bit calculations.
     
    Here is the source code for that page incase anyone wants to update it to also manage 16 bit calculations. I'll be happy to host the updated version for people who do not wish to work with M$ applications or who just need a quick calculation from the web.
     

     [size=1]
    [size=1]
    for intSPBRG = 255 to 0 step -1
      dTemp1 = (intSPBRG+1.0) * 64.0
      debug dTemp1
      dBaud0 = fOSCILLATOR / dTemp1
      debug dBaud0
      intSPBRG0 = intWithin3Percent(dBaud0)

      dTemp1 = (intSPBRG+1.0) * 16.0
      dBaud1 = fOSCILLATOR / dTemp1
      intSPBRG1 = intWithin3Percent(dBaud1)
      if intSPBRG0>0 or intSPBRG1>0 then
        response.write "<TR>"
        response.write "<TD ALIGN='RIGHT'>" & intSPBRG & "</TD>"
        response.write "<TD>"
        if intSPBRG0>0 then
          PercentErr = (1-(int(dBaud0)/intSPBRG0))*100
          response.write FormatNumber(dBaud0,2)
          if abs(PercentErr) > 1.5 then response.write "<FONT color=#800000>"
          if abs(PercentErr) < 0.5 then response.write "<FONT color=#008000>"
          response.write " <SMALL>("&intSPBRG0&" "& FormatNumber(PercentErr,1) & "%)</SMALL>"
          if abs(PercentErr) > 1.5 or abs(PercentErr) < 0.5 then response.write "</FONT>"
          end if
        response.write "&nbsp;</TD>"
        response.write "<TD>"
        if intSPBRG1>0 then
          PercentErr = (1-(int(dBaud1)/intSPBRG1))*100
          response.write FormatNumber(dBaud1,2)
          if abs(PercentErr) > 1.5 then response.write "<FONT color=#800000>"
          if abs(PercentErr) < 0.5 then response.write "<FONT color=#008000>"
          response.write " <SMALL>("&intSPBRG1&" "& FormatNumber(PercentErr,1) & "%)</SMALL>"
          if abs(PercentErr) > 1.5 or abs(PercentErr) < 0.5 then response.write "</FONT>"
          end if
        response.write "&nbsp;</TD>"
        response.write "</TR>"
        end if
      next
    [/size]
    [/size]


    aspforum.mchp.guest
    #9
    Dredd
    Super Member
    • Total Posts : 549
    • Reward points : 0
    • Joined: 2003/11/07 12:36:53
    • Location: Montreal, Canada
    • Status: offline
    RE: Revised SPBRG Calc... 2006/08/03 18:00:21 (permalink)
    0
    Its not related to the subject, But i just want to thank you (JamesNewton) for the magnificent job you do with your site. If you need some code related to pic, piclist is the site to go.
     
    Just wanted to say thanks for the many times you're site got me out of troubles wink
    #10
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: Revised SPBRG Calc... 2008/03/31 06:43:58 (permalink)
    +2 (1)
    Somehow the PC application (http://www.wowway.com/~mmclaren/K8LH%20SPBRG%20Calc%20v11.exe) does not run here.
     
    Error Message pop-up:
    Runtime Error: index: 0 is outside of collection bounds (see error.log for more information).
     
    And I have to manually kill the process in Windows task manager.
     
    Error.log:

    Error log timestamp Monday 03/31/08 09:40:02 PM
    Runtime error: index: 0 is outside of collection bounds
    Error(Exception)>>defaultAction
    Error(Exception)>>activateHandler: <anUndefinedObject>
    Error(Exception)>>handle
    Error(Exception)>>signal
    Error class(Exception class)>>signal: <'index: 0 is outside ...'>
    OrderedCollection(Object)>>error: <'index: 0 is outside ...'>
    OrderedCollection(IndexedCollection)>>errorInBounds: <0>
    OrderedCollection>>at: <0> put: <anOrderedCollection>
    BasicOnDemandCompiler class>>readTknFile: <aMixedFileStream> callingProgram: <anUndefinedObject> commandLine: <''>
    Basic class>>start
    Message>>perform
    NotificationManager>>empty
    NotificationManager>>runPendingEvents
    NotificationManager>>runEventLoop
    Message>>perform
    Message>>evaluate
    Process>>safelyEvaluate: <aMessage>
    Process>>evaluate: <aMessage>

      USB_Links and libusb
    #11
    paulbergsman
    Super Member
    • Total Posts : 1517
    • Reward points : 0
    • Joined: 2006/05/25 12:18:23
    • Location: Merion Station, Penna.
    • Status: offline
    RE: Revised SPBRG Calc... 2008/03/31 07:19:46 (permalink)
    0
    ORIGINAL: K8LH

    For those who may be interested, I have revised the Excel 2000 SPBRG Calculator spreadsheet to support the 16 bit SPBRG modes available on some newer devices, like the16F690 and 18F2620 (and others)...

    Regards, Mike


    VERY NICE!

    #12
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Revised SPBRG Calc... 2008/03/31 09:52:36 (permalink)
    0
    ORIGINAL: xiaofan

    Somehow the PC application (http://www.wowway.com/~mmclaren/K8LH%20SPBRG%20Calc%20v11.exe) does not run here.



    Hi Xiaofan, it's ok in here: Windows 2000 SP4...

    I can just see (never used it before) that some Redraw inside the Window does not work correctly in some cases, and also when you change Clock Freq, you have to hit Return but it's not obvious.

    GENOVA :D :D ! GODO
    #13
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: Revised SPBRG Calc... 2008/04/03 05:11:43 (permalink)
    0
    http://www.mister-e.org/pages/utilitiespag.html
     
    This seems to work and it has quite some other functions.

      USB_Links and libusb
    #14
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: Revised SPBRG Calc... 2008/04/04 02:21:50 (permalink)
    0
    Thank you Xiaofan.
    As Olin once said, I don't usually use such tools gringrin but I'll store it... you never know!

    GENOVA :D :D ! GODO
    #15
    magicrub
    Starting Member
    • Total Posts : 75
    • Reward points : 0
    • Joined: 2007/05/16 17:45:58
    • Location: Santa Cruz, Ca. USA
    • Status: offline
    RE: Revised SPBRG Calc... 2008/04/07 15:36:34 (permalink)
    0
    Other than backwards compatability reasons, why would I ever want to use an 8bit divider on an 18F chip?
     
    Even if the 8 bit and 16bit give you zero error, why not just always use 16?

    -Tom
    #16
    K8LH
    Super Member
    • Total Posts : 1887
    • Reward points : 0
    • Joined: 2004/03/26 05:12:34
    • Location: Michigan, USA
    • Status: offline
    RE: Revised SPBRG Calc... 2008/04/20 02:25:55 (permalink)
    0
    Hi Tom,

    Not all 18F' devices have the 16 bit SPBRG divider chain and only a few 16F' devices have it.

    Regards, Mike
    #17
    Jump to:
    © 2021 APG vNext Commercial Version 4.5