# Vault 7: Projects

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

### Protego

# PIC24FJ32MC10X -- UART

- 1
- 2
…
- 16
- 17
- 18
- 19
- 20
…
- 55
- 56

dsPIC33/PIC24 Family Reference Manual
DS70000582E-page 18  2009-2013 Microchip Technology Inc.
Example 5-1: UART1 Transmission with Interrupts
#define FP 40000000
#define BAUDRATE 9600
#define BRGVAL ((FP/BAUDRATE)/16)-1
unsigned int i;
#define DELAY_105uS asm volatile ("REPEAT, #4201"); Nop(); // 105uS delay
int main(void)
{
// Configure oscillator as needed
.
.
.
// Configure oscillator as needed
U1MODEbits.STSEL = 0; // 1-Stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-Data bits
U1MODEbits.ABAUD = 0; // Auto-Baud disabled
U1MODEbits.BRGH = 0; // Standard-Speed mode
U1BRG = BRGVAL; // Baud Rate setting for 9600
U1STAbits.UTXISEL0 = 0; // Interrupt after one TX character is transmitted
U1STAbits.UTXISEL1 = 0;
IEC0bits.U1TXIE = 1; // Enable UART TX interrupt
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable UART TX
/* Wait at least 105 microseconds (1/9600) before sending first char */
DELAY_105uS
U1TXREG = 'a'; // Transmit one character
while(1)
{
}
}
void __attribute__((__interrupt__)) _U1TXInterrupt(void)
{
IFS0bits.U1TXIF = 0; // Clear TX Interrupt flag
U1TXREG = 'a'; // Transmit one character
}

- 1
- 2
…
- 16
- 17
- 18
- 19
- 20
…
- 55
- 56