Fbus = XTAL/4 2.4576 MHz *
Baud Rate = -------------------- = ---------- = 9600 bps *
64 x SCP1:0 x SCR2:0 64 x 1 x 4 *
SCBR = 0x02; /* Select a baud rate of 9600 bps with Fbus = 2.4576 MHz */
thanks
Hi CCandido,
Not real sure I understand your question, but I will throw this at you.
With the GP, to select the baudrate you have two things to adjust, the Prescaler and the BR Divisor.
What type of bus frequency you have determines the prescaler i.e.
if you have an even high frequency xtal, like 32MHz for 8MHz then you use 11 for the prescaler to give you a standard baudrate. Then you can use the divisor to get lower stadard baudrates than that.
If you use the PLL to get frequencies like 7.3728MHz then you use 01 or 00 for 4.9MHz.
So its no good trying to do a calculation in one go.
Just lock in a Prescaler based on your buss frequency then allow selection of the allowable range of standard baudrates using the baudrate divisor.
hope this helps
Peg
Yes, so 8M / 64 / 13 = 9615baud
then you can only go down from here to 4800, 2400, 1200 etc
If you want a better range use 7.3728MHz from PLL
Then 7.3728M / 3 / 1 = 38,400baud.
Now you can use the divisor to get 19,200, 9600, 4800 etc
BR Peg
Message Edited by rocco on 04-14-200610:18 PM
Hi Carlos,
If you stay with a fixed buss frequency there is only so many baudrates you can achieve and many of these will be non-standard.
I have created a table that lists all of the possible baudrates for buss frequencies of 8MHz and for 7.3728MHz
, ,8000000,7372800
64, , 125000, 115200
1, 1, 125000, 115200
1, 2, 62500, 57600
1, 4, 31250, 28800
1, 8, 15625, 14400
1, 16, 7813, 7200
1, 32, 3906, 3600
1, 64, 1953, 1800
1,128, 977, 900
3, 1, 41667, 38400
3, 2, 20833, 19200
3, 4, 10417, 9600
3, 8, 5208, 4800
3, 16, 2604, 2400
3, 32, 1302, 1200
3, 64, 651, 600
3,128, 326, 300
4, 1, 31250, 28800
4, 2, 15625, 14400
4, 4, 7813, 7200
4, 8, 3906, 3600
4, 16, 1953, 1800
4, 32, 977, 900
4, 64, 488, 450
4,128, 244, 225
13, 1, 9615, 8862
13, 2, 4808, 4431
13, 4, 2404, 2215
13, 8, 1202, 1108
13, 16, 601, 554
13, 32, 300, 277
13, 64, 150, 138
13,128, 75, 69
I have highlighted all the standard baudrates
As I said before you can try and calculate it if you like but by the time you round it off and indicate the ones you can't acheive etc you will be better off with a simple switch statement.
int init_sci(baud){
switch (baud){
case 115200:
SCBR = 0x00;
break;
case 57600;
SCBR = 0x01;
etc
default:
return -1;
}
return 0;
}
BR Peg
Message Edited by peg on 04-16-200610:57 AM
Hi Carlos,
Are you trimming the ICG?
At 8MHz there is already a baudrate error and lack of trim could make it worse.
At 7.3MHz you have exact baudrate and the lack of trim may not be enough to stop it working.
In the future could you include the original text Portuguese because I am struggling with the translated versions.
Go the socceroos!
Adeus
Peg
Hi all,
Just today I flashed a board (GT16) and my serial comms didn't work.
After some fiddling I found I forgot to trim the ICG. Once trimmed it worked.
Then I did some experimenting and found that inside about +/- 7% a PC terminal can communicate with virtually no errors and just outside 7% you get about 1 garbled char in 5.
The greater majority of trims required that I have seen fall over a slightly larger spread than this.
Just something to keep in mind!
BR Peg
I guess I should add this was at 9600 baud.
Message Edited by peg on 04-19-200608:55 PM
Hi,
Like I said before the maximum standard baudrate you can achieve with a 32k xtal and a 8M buss is 9600 baud.
You could use a switch statement to set the divisor for the std baudrates below this I guess.
BR Peg