FCY = 4 MHz

Desired Baud Rate = 9600

What is the value we must put in BRG register?
BRG = ?

3 answers

To calculate the value to put in the BRG (Baud Rate Generator) register, we can use the following formula:

BRG = (FCY / (16 * Desired Baud Rate)) - 1

Plugging in the given values:

BRG = (4 MHz / (16 * 9600)) - 1

Simplifying:

BRG = (4000000 / 153600) - 1

BRG ≈ 25.98

Since the BRG value must be an integer, we will round up to the nearest whole number:

BRG = 26
Calculated Baud rate?
Error?
To calculate the calculated baud rate, we can use the following formula:

Calculated Baud Rate = FCY / (16 * (BRG + 1))

Plugging in the given values:

Calculated Baud Rate = 4 MHz / (16 * (26 + 1))

Simplifying:

Calculated Baud Rate = 4000000 / (16 * 27)

Calculated Baud Rate ≈ 9259.26

Now, to calculate the error:

Error = (Calculated Baud Rate - Desired Baud Rate) / Desired Baud Rate * 100

Error = (9259.26 - 9600) / 9600 * 100

Error ≈ -3.59%

Therefore, the calculated baud rate is approximately 9259.26 with an error of approximately -3.59%.