
This example shows how to implement a command line interface, enabling the microcontroller (MCU) to receive control commands via the Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART). In this use case, an LED is controlled using commands sent from the MPLAB® Data Visualizer.
- TB3282 – Getting Started With UART Using EUSART on PIC18
- PIC18-Q10 Product Family
- PIC18F47Q10 Product Page
- PIC18F47Q10 Data Sheet
- PIC18F47Q10 Curiosity Nano
- PIC18F47Q10 Code Examples on GitHub
-
The PIC18F47Q10 Curiosity Nano development board is used as a test platform:
The PIC18F47Q10 Curiosity Nano development board has an on-board debugger that acts as an USART-to-USB convertor so no further hardware is needed.
The following configurations must be made for this project:
Pin | Configuration |
---|---|
RD0 (EUSART2 - TX) | Digital output |
RD1 (EUSART2 - RX) | Digital input |
RE0 (LED0) | Digital output |
Run the code and configure the Data Visualizer as described in the referenced technical brief document. Type commands to be sent to the board. The two available commands are "ON" and "OFF". Observe the LED on the board as it changes its state according to the command sent. It is convenient to use the line terminator as command delimiter, so for this use case, EUSART will read full lines and then check if the line contains a valid command.
This demo showcases how EUSART can be used to implement a command line interface, allowing the MCU to receive commands via EUSART.
This chapter shows how to use the MPLAB X IDE to program a PIC® device with an ExampleProject.X
. This can be applied to any other projects.
-
Connect the board to the computer.
-
Open the
ExampleProject.X
project in MPLAB X IDE. -
Set the ExampleProject project as main project.
Right click the project in the Projects tab and click Set as Main Project.
-
Clean and build the ExampleProject project.
Right click the ExampleProject project and select Clean and Build.
-
Select the PIC Curiosity Nano in the Connected Hardware Tool section of the project settings:
- Right click the project and click Properties
- Click the arrow under the Connected Hardware Tool
- Select the PIC Curiosity Nano, click Apply and then click OK:
-
Program the project to the board.
Right click the project and click Make and Program Device.