AtomSoft
Well-Known Member
Hello all i wanted to ask something that may be simple...
I wanted to send data at 4800bps i usually just get the info from the data sheet but this isnt a common speed i guess heh...
So i need to do the calculations. Now the issue is :
1. Im not sure if im right...
2. I have 2 speeds 1 micro is 20mhz and the other is 40mhz so im doing it for both..
The PIC in question is a 18F2525..
From Datasheet:
20Mhz:
20000000/4800 = 4166.666666666667
4166.666666666667 / 64 = 65.10416666666667
65.10416666666667 - 1 = 64.10416666666667
64.10416666666667 = 64
((20000000/4800)/64)-1 = 64
20000000/(64(64+1)) = 4807.692307692308
(4807.692307692308 - 4800)/4800 = 0.0016025641025642 %
Correct?
40Mhz:
40000000/4800 = 8333.333333333333
8333.333333333333 / 64 = 130.2083333333333
130.2083333333333 - 1 = 129.2083333333333
129.2083333333333 = 129
((40000000/4800)/64)-1 = 129
40000000/(64(129+1)) = 4807.692307692308
(4807.692307692308 - 4800)/4800 = 0.0016025641025642 %
Correct?
Exact same speed.... Would these values work ? I find it a pain in the butt to test 2 PICs communicating.... so i want to ask before i go nuts if i get some bad results heh i know it wasnt this...
EDIT:
I remember there being a calculator of some sort or a speed sheet formula... i dont know how to use those really to make my own but would love if someone can repost them heh
I wanted to send data at 4800bps i usually just get the info from the data sheet but this isnt a common speed i guess heh...
So i need to do the calculations. Now the issue is :
1. Im not sure if im right...
2. I have 2 speeds 1 micro is 20mhz and the other is 40mhz so im doing it for both..
The PIC in question is a 18F2525..
From Datasheet:
For a device with FOSC of 16 MHz, desired baud rate of 9600, Asynchronous mode, 8-bit BRG:
Desired Baud Rate = FOSC/(64 ([SPBRGH:SPBRG] + 1))
Solving for SPBRGH:SPBRG:
X = ((FOSC/Desired Baud Rate)/64) – 1
= ((16000000/9600)/64) – 1
= [25.042] = 25
Calculated Baud Rate = 16000000/(64 (25 + 1))
= 9615
Error = (Calculated Baud Rate – Desired Baud Rate)/Desired Baud Rate
= (9615 – 9600)/9600 = 0.16%
20Mhz:
20000000/4800 = 4166.666666666667
4166.666666666667 / 64 = 65.10416666666667
65.10416666666667 - 1 = 64.10416666666667
64.10416666666667 = 64
((20000000/4800)/64)-1 = 64
20000000/(64(64+1)) = 4807.692307692308
(4807.692307692308 - 4800)/4800 = 0.0016025641025642 %
Correct?
40Mhz:
40000000/4800 = 8333.333333333333
8333.333333333333 / 64 = 130.2083333333333
130.2083333333333 - 1 = 129.2083333333333
129.2083333333333 = 129
((40000000/4800)/64)-1 = 129
40000000/(64(129+1)) = 4807.692307692308
(4807.692307692308 - 4800)/4800 = 0.0016025641025642 %
Correct?
Exact same speed.... Would these values work ? I find it a pain in the butt to test 2 PICs communicating.... so i want to ask before i go nuts if i get some bad results heh i know it wasnt this...
EDIT:
I remember there being a calculator of some sort or a speed sheet formula... i dont know how to use those really to make my own but would love if someone can repost them heh
Last edited: