Uart Mcu
Uart Mcu
Uart Mcu
Microcontrollers
Corrado Santoro
L.A.P. 1 Course
UART Setup
...
// setup UART
TRISCbits.TRISC6 = 0; // TX as output
TRISCbits.TRISC7 = 1; // RX as input
... or, you can use directly the printf function, provided that you
implement a proper putch(char c) function, that is then called
by printf for each character to send.
Using printf
void putch(char c) {
// wait the end of transmission
while (TXSTA1bits.TRMT == 0) {};
TXREG1 = c; // send the new byte
}
...
printf("Hello world!!");
...
Corrado Santoro
L.A.P. 1 Course