SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 255 | Next

Jan Axelson

"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems"

Round((fosc / (multiplier * bitRate)) - 1)
spbrg is the 8-bit value in SPBRG or the 16-bit value in SPBRGH and SPBRG.
If BRG16 = 0, SPBRG must be 255 or less. If the calculated spbrg value is
slightly higher than 255, setting SPBRG to 255 might result in a usable bit rate.
fosc is the FOSC value in Hz.
Ports for Embedded Systems
237
The value of the multiplier variable depends on the values in BRG16 and
BRGH:
If multiplier = 16 and spbrg < 256, firmware can achieve the same bit rate by
setting BRGH = 1 and BRG16 = 0 or by setting BRGH = 0 and BRG16 =1. If
multiplier = 16 and spbrg > 255, firmware must set BRGH = 0 and BRG16 = 1.
bitRate is the desired bit rate.
To find the setting that results in the closest bit rate to the desired value, perform
the calculation with each of the three multiplier values. This formula calculates
the actual bit rate that results from specific values:
actualBitRate = Round(fosc / (multiplier * (spbrg + 1)))
The fosc and multiplier variables are set as described above. Depending on the
value of BRG16, spbrg is the 8-bit value in SPBRG or the 16-bit value in
SPBRGH and SPBRG. If BRG16 = 1 and spbrg is greater than 255, you need
to divide spbrg into its lower and higher bytes:
spbrgl = spbrg Mod 256
spbrgh = Int(spbrg / 256)
A carefully selected FOSC frequency can result in a calculated bit rate with zero
error. However, the hardware oscillator can still introduce error if the oscillator
doesn??™t operate at exactly its rated frequency.


Pages:
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267