The 'pic16f15244-eusart-example' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to transmit "Hello World!" to a PC terminal application using the EUSART module.
- MPLAB® X IDE 6.15
- MPLAB® XC8 2.45
- MPLAB® Code Configurator (MCC) 5.3.7
- Microchip PIC16F1xxxx Series Device Support (1.20.366)
- PIC16F15244 Curiosity Nano
- Micro-USB to USB 2.0 cable
- Connect the PIC16f15244 Curiosity Nano board to a PC using the Micro-USB to USB 2.0 cable.
- If not already on your system, download and install MPLABX IDE version 6.15 or newer.
- If not already on your system, download and install the XC8 C-Compiler version 2.45 or newer.
- Open the 'pic16f15244-eusart-example.X' project (see Figure 1).
- Click on the 'Project Properties' button to open the Project Properties window. Select the Curiosity tool from the Connected Hardware Tool drop-down menu (see Figure 2).
- Click on the 'Make and Program Device' button to program the PIC (see Figure 3). Verify that the device is successfully programmed (see Figure 4).
- Open a terminal program on your PC. For this example, Tera Term was used as the terminal program.
a. Port Selection is used by the Nano board (see Figure 5).
b. Configure the serial port (see Figure 6).
After the Nano board is programmed, the EUSART module will transmit the string "Hello World!" to the PC terminal window at a baud rate of 9600 bps. Output pin RC0 is configured as the TX output through PPS. Nano hardware also connects pin RC0 to the USB receive line, allowing a quick connection to the PC terminal without any additional wires or USB bridge circuits.
The EUSART module is configured to use the printf()
function call that is built into the XC8 libraries. In MCC, simply mark the 'Redirect STDIO to USART' check-box (see Figure 7), and the additional function call are added to the project. Example 1 shows the use of the printf()
function.
void main(void)
{
SYSTEM_Initialize(); // Initialize the device
while (1)
{
printf("Hello World! \r\n"); // Write over EUSART
__delay_ms(2000); // Two second delay
}
}
The 'pic16f15244-eusart-example' code example uses the PIC16F15244 Curiosity Nano Development board to demonstrate how to transmit "Hello World!" to a PC terminal application using the EUSART module. Once programmed, the EUSART will transmit the string 'Hello World!' to a PC terminal program.