English
Language : 

C8051F50X_11 Datasheet, PDF (203/313 Pages) Silicon Laboratories – Mixed Signal ISP Flash MCU Family
C8051F50x/F51x
Use the following equations to calculate the values for the variables for the baud-rate equation:
multiplier
=
-------2---0----0---0---0---------
baud_rate
–
1
prescaler = ln
---m-----u----l--t--i-p----l--i-e----r----+----S-1----Y----S----C-b----aL---u-K---d----_---r---a---t--e-----------2----0---0--
 ---1----- – 1
ln2
divider = -------------------------------------------------------S----Y-----S----C-----L---K---------------------------------------------------------
2prescaler + 1  multiplier + 1  baud_rate
In all of these equations, the results must be rounded down to the nearest integer.
The following example shows the steps for calculating the baud rate values for a Master node running at
24 MHz and communicating at 19200 bits/sec. First, calculate the multiplier:
Next, calculate the prescaler:
multiplier = 2----0---0----0---0-- – 1 = 0.0417  0
19200
prescaler
=
l n ---0-----+-----1----2---4----0--1-0--9-0---2-0--0-0--0-0----------2----0---0--

---1----- – 1
ln2
=
1.644

1
Finally, calculate the divider:
divider = -----------------------2---4----0---0---0----0---0---0------------------------ = 312.5  312
21 + 1  0 + 1  19200
These values lead to the following baud rate:
baud_rate = 2------1-----+-----1----2---4---0----0--0-0---0-+---0--1-0------------3----1---2--  19230.77
The following code programs the interface in Master mode, using the Enhanced Checksum and enables
the interface to operate at 19230 bits/sec using a 24 MHz system clock.
LIN0CF = 0x80;
LIN0CF |= 0x40;
// Activate the interface
// Set the node as a Master
LIN0ADR = 0x0D;
// Point to the LIN0MUL register
// Initialize the register (prescaler, multiplier and bit 8 of divider)
LIN0DAT = ( 0x01 << 6 ) + ( 0x00 << 1 ) + ( ( 0x138 & 0x0100 ) >> 8 );
LIN0ADR = 0x0C;
// Point to the LIN0DIV register
LIN0DAT = (unsigned char)_0x138;
// Initialize LIN0DIV
LIN0ADR = 0x0B;
LIN0DAT |= 0x80;
// Point to the LIN0SIZE register
// Initialize the checksum as Enhanced
LIN0ADR = 0x08;
LIN0DAT = 0x0C;
// Point to LIN0CTRL register
// Reset any error and the interrupt
Rev. 1.2
203