This repository provides an MCC Melody-generated code example for an external interrupt wake-up using the MPLAB® X project.
More details and code examples on the AVR128DA48 can be found at the following links:
- MPLAB® X IDE v6.05 or newer
- MPLAB® XC8 2.40 or newer
- MPLAB® Data Visualizer
- AVR-Dx v2.3.272 Device Family Pack or newer
- Logic analyzer software
-
AVR128DA48 Curiosity Nano Development Board is used as a test platform. (DM164151)
-
Oscilloscope or Logic Analyzer
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.
The following peripheral and clock configurations are set up using MCC Melody for the AVR128DA48:
-
Clock Control:
-
Interrupt Manager:
-
SLPCTRL:
-
Pin Grid View:
-
Pins:
The following pin configuration must be made for this project:
Pin | Configuration | Function |
---|---|---|
PC6 | Digital Output | GPIO Pin - LED0 |
PC7 | Digital Input | GPIO Pin - SW0 |
In the main loop, the program starts by entering the CPU in Sleep Mode. When the button is pressed, the CPU wakes up and the LED starts blinking. After those operations, the CPU returns to Sleep Mode. The flowchart diagram is represented in the below picture:
To demonstrate the functionality of the example, the SW0 (PC7) push button and LED0 (PC6) on board LED are used as in the next demo:
The next snapshot from the logic analyzer software demonstrates the fixed amount of time while the LED0 is turned on (200 ms), with different trigger times of the pressed button.
NOTE: The on-board LED is turned on while the signal is low, and the button is pressed while the signal is low too.
This example demonstrates a simple implementation of a sleep operation with an external interrupt triggering an LED blink.
This chapter shows how to use the MPLAB X IDE to program an AVR® device with an Example_Project.X. This can be applied for any other projects.
-
Connect the board to the PC.
-
Open the Example_Project.X project in MPLAB X IDE.
-
Set the Example_Project.X project as main project.
-
Clean and build the Example_Project.X project.
-
Select the AVRxxxxx Curiosity Nano in the Connected Hardware Tool section of the project settings:
-
Program the project to the board.