English
Language : 

C8051F54X_14 Datasheet, PDF (172/275 Pages) Silicon Laboratories – Mixed Signal ISP Flash MCU Family
C8051F54x
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
=
ln---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------1-----+-----1-------2---4----0--0-0---0-+---0--1-0---0---------1----9---2---0----0- = 312.5  312
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;
// Point to LIN0CTRL register
LIN0DAT = 0x0C;
// Reset any error and the interrupt
Table 19.2 includes the configuration values required for the typical system clocks and baud rates:
172
Rev. 1.1