Skip to content

microchip-pic-avr-examples/avr128da48-cnano-ext-int-wakeup-mcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

External Interrupt Wake-Up Example using the AVR128DA48 Microcontroller with MCC Melody

This repository provides an MCC Melody-generated code example for an external interrupt wake-up using the MPLAB® X project.

Related Documentation

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

Software Used

Hardware Used

  • AVR128DA48 Curiosity Nano Development Board is used as a test platform. (DM164151)

  • Oscilloscope or Logic Analyzer

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.

1. Setup

The following peripheral and clock configurations are set up using MCC Melody for the AVR128DA48:

  • Clock Control:

    • Default settings (Main Clock: 4 MHz)
  • Interrupt Manager:

    • Global Interrupt Enable: Enabled
  • SLPCTRL:

    • Sleep Enable: Enabled
    • Sleep Mode: Idle
    • Performance Mode: Auto
  • Pin Grid View:

    • GPIO Input: PC7
    • GPIO Output: PC6
  • Pins:

    • PC6:
      • GPIO
      • Output
      • Custom Name: LED0
      • Inverted I/O: Enabled
    • PC7:
      • GPIO
      • Input
      • Custom Name: SW0
      • Pull-up: Enabled
      • Input/Sense Configuration: Sense Falling Edge

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

2. Demo:

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.

3. Summary

This example demonstrates a simple implementation of a sleep operation with an external interrupt triggering an LED blink.

How to Program the Curiosity Nano board

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.

    • Right click on the project in the Projects tab and click Set as Main Project.
  • Clean and build the Example_Project.X project.

    • Right click on the Example_Project.X project and select Clean and Build.
  • Select the AVRxxxxx Curiosity Nano in the Connected Hardware Tool section of the project settings:

    • Right click on the project and click Properties
    • Click on the arrow under the Connected Hardware Tool
    • Select the AVRxxxxx Curiosity Nano (click on the SN), click Apply and then click OK:
  • Program the project to the board.

    • Right click on the project and click Make and Program Device.