Posts: 1545
Joined: Mar. 26, 2004
From: Michigan, USA
Status: offline
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...
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.
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.
< Message edited by potholer -- Aug. 2, 2006 4:55:47 PM >
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 " </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 " </TD>"
response.write "</TR>"
end if
next
[/size]
[/size]
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
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)...
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.