# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ64GA004 -- UART

- 1
- 2
…
- 10
- 11
- 12
- 13
- 14
…
- 55
- 56

dsPIC33/PIC24 Family Reference Manual
DS70000582E-page 12  2009-2013 Microchip Technology Inc.
3.0 UART BAUD RATE GENERATOR
The UART module consists of a dedicated 16-bit Baud Rate Generator. The UxBRG register
controls the period of a free-running, 16-bit timer. Equation 3-1 shows the formula for computing
the baud rate with BRGH = 0.
Equation 3-1: UARTx Baud Rate (BRGH = 0)
Equation 3-2 shows the calculation of baud rate error for the following conditions:
 F
P = 4 MHz
 Desired Baud Rate = 9600
Equation 3-2: Baud Rate Error Calculation (BRGH = 0)
The maximum baud rate (BRGH = 0) possible is F
P/16 (for UxBRG = 0) and the minimum baud
rate possible is F
P/(16 * 65536).
Equation 3-3 shows the formula for computing the baud rate with BRGH = 1.
Equation 3-3: UARTx Baud Rate (BRGH = 1)
The maximum baud rate (BRGH = 1) possible is F
P/4 (for UxBRG = 0) and the minimum baud
rate possible is F
P/(4 * 65536).
Writing a new value to the UxBRG register causes the BRG timer to reset (cleared). This ensures
the BRG does not wait for a timer overflow before generating the new baud rate.
Note: FP denotes the instruction cycle clock frequency (FOSC/2).
Baud Rate
F
P
16 UxBRG 1+ 
----------------------------------------------=
UxBRG
F
P
16 Baud Rate
------------------------------------- 1–=
...... (1)
...... (2)
Desired Baud Rate
F
P
16 UxBRG 1+ 
----------------------------------------------=
Solving for UxBRG Value:
UxBRG
F
P Desired Baud Rate
16
-------------------------------------------------------- 1–=
Calculated Baud Rate
4000000
16 25 1+ 
--------------------------------=
Error
Calculated Baud Rate Desired Baud Rate–
Desired Baud Rate
--------------------------------------------------------------------------------------------------------=
9615 9600–
9600
------------------------------=
0.16%=
4000000 9600
16
------------------------------------- 1–
 
 
=
25=
...... (1)
...... (2)
9615=
Note: FP denotes the instruction cycle clock frequency.
Baud Rate
F
P
4 UxBRG 1+ 
-------------------------------------------=
UxBR G
F
P
4 Baud Rate
---------------------------------- 1–=
...... (1)
...... (2)

- 1
- 2
…
- 10
- 11
- 12
- 13
- 14
…
- 55
- 56