Skip to content

This example uses the MCC Melody Library to show how to configure the device with a software delay and blink the LED on the AVR128DB48 Curiosity Nano development kit.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/avr128db48-blink-sw-delay-mplab-mcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

LED Blink using software delay

This example shows how to configure an LED to blink periodically using drivers in MPLAB Code Configurator (MCC). The example uses the Pin Manager to configure the pin and generate an API with which the pin is later interfaced. Also, the delay driver is used to implement periodic timeouts between each time the pin output is toggled.

Related Documentation

Software Used

Hardware Used

Setup

This example uses MCC with the Melody library, as shown below.

Delay Driver

The Delay Driver was simply added to the project by locating it in the Device Resources pane on the left side in MCC and clicking the green plus icon as shown in the image below.

Device Resources

MCC - Adding Delay Driver

When the Delay Driver was added, it was shown in the Project Resources and in the Builder view as seen below.

Project Resources

MCC - Project Resources with Delay

Builder

MCC - Builder with Delay

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, PB3, was selected as an output by clicking the corresponding padlock symbol.

Pins Grid View

MCC - Set Pin to Output

The pin was also configured with a custom name to make the generated API more readable.

Custom Pin Name

MCC - Custom Pin Name

Code Implementation

First, the delay functions were included in the application by including the MCC generated API:

#include "mcc_generated_files/timer/delay.h"

Then the pin manager and delay APIs were used to toggle the LED-pin once every 500 ms:

while(1)
    {
        LED_PIN_Toggle();
        DELAY_milliseconds(500);
    }    

Operation

After having flashed the application to the AVR128DB48 Curiosity Nano, the onboard LED blinks with a frequency of 1 Hz.

blinky_gif

Summary

The example has shown how MCC can be used to create APIs which may easily be used in application code. The use of such APIs make the code readable and simple, while the functions are generated automatically as configured in MCC.

About

This example uses the MCC Melody Library to show how to configure the device with a software delay and blink the LED on the AVR128DB48 Curiosity Nano development kit.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published