/pic18f57q43-hello-world-mplab-mcc

This example code hello world will setup ports and blink Led

Primary LanguageCOtherNOASSERTION

MCHP

Hello World

This example shows how to configure the LED on the PIC18F57Q43 Curiosity Nano to light up using drivers in MPLAB Code Configurator (MCC). The example uses the Pin Manager to configure the correct pin to be an output and to provide the correct output voltage for lighting the LED.

Related Documentation

Software Used

Hardware Used

Setup

MCC with the Melody library was used to implement this example as shown in the following section.

Pin Configuration

The Pin controlling the onboard LED on the Curiosity Nano board was configured using the Pins Grid View. The Pins Grid View is accessed by clicking on the Pins line in Project Resources.

Project Resources MCC - Open Pin Manager

Then the pin connected to the LED, RF3, was selected as an output by clicking the corresponding padlock symbol.

Pins Grid View MCC - Set Pin to Output

RF3 has both digital and analog capability the pin will have to be configured as digital only the analog checkbox is selected by default. The user must click the checkbox to deselect the analog function from the pin. The pin was also configured with a custom name to make the generated API more readable.

Pins Tab

MCC - Custom Pin Name and Analog Output

Since the LED on the Curiosity Nano board is active low, that is, lighting up when the pin outputs a low voltage, the pin needs no further configuration. As seen below, the checkbox named "Start High" is not checked, so the pin starts with a low output.

Start High Not Enabled

MCC - Custom Pin Name

The API is not needed in this application since the pin does not change, but if the user would like to configure it, the API makes it easy to reconfigure the pin in the code. For example, the code below could be used to toggle the output voltage of the pin from high to low or vice versa:

LED_PIN_Toggle();

Operation

After having flashed the application to the PIC18F57Q43 Curiosity Nano, the onboard LED is lit.

Summary

The example has shown how MCC can be used to easily configure the pins of the PIC18F57Q43 device.