Skip to content

This example shows how to implement a command line interface. This way, the microcontroller can receive control commands via the EUSART. In this use case, an LED is controlled using commands sent from the MPLAB Data Visualizer.

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f47q10-cnano-eusart-commands-mcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

Receive Control Commands via EUSART Using the PIC18F47Q10 Microcontroller With MCC Melody

This example shows how to implement a command line interface. This way, the microcontroller can receive control commands via the EUSART. In this use case, an LED is controlled using commands sent from the MPLAB® Data Visualizer.

Related Documentation

More details and code examples on the PIC18F47Q10 can be found at the following links:

Software Used

Hardware Used

Operation

To program the Curiosity Nano board with this MPLAB X project, follow the steps provided in the How to Program the Curiosity Nano Board chapter.

Setup

The following peripheral and clock configurations are set up using the MPLAB Code Configurator (MCC) Melody for the PIC18F47Q10:

  1. Clock Control:
  • Clock Source: HFINTOSC
  • HF Internal Clock: 4 MHz
  • Clock Divider: 4
  1. UART2:
  • UART PLIB Selector: EUSART2
  • Requested Baud Rate: 9600
  • Data Size: 8
  • Redirect Printf to Uart: Enabled
  1. EUSART2 Peripheral:
  • Receive Enable: Enabled
  • Clock/Transmit Polarity: Non-Inverted
  • Serial Port Enable: Enabled
  • Transmit Enable: Enabled
  • Baud Rate Generator: 16-bit generator
  • Baud Rate Generator Speed Select: High speed
  1. Pins:
  • RD1 - EUSART2 TX
  • RD0 - EUSART2 RX
  • RE0 - LED0, Start High

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

Demo

Run the code and configure the Data Visualizer as described in the 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.


Summary

One important usage of the EUSART represents the implementation of a command line interface. This way, the microcontroller can receive control commands via EUSART. 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.

How to Program the Curiosity Nano Board

This chapter demonstrates how to use the MPLAB X IDE to program a PIC® device with an Example_Project.X. This is applicable to other projects.

  1. Connect the board to the PC.

  2. Open the Example_Project.X project in MPLAB X IDE.

  3. Set the Example_Project.X project as main project.
    Right click the project in the Projects tab and click Set as Main Project.

  4. Clean and build the Example_Project.X project.
    Right click the Example_Project.X project and select Clean and Build.

  5. Select PICxxxxx 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 PICxxxxx Curiosity Nano (click the SN), click Apply and then click OK:

  6. Program the project to the board.
    Right click the project and click Make and Program Device.



Menu

About

This example shows how to implement a command line interface. This way, the microcontroller can receive control commands via the EUSART. In this use case, an LED is controlled using commands sent from the MPLAB Data Visualizer.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •