This repository provides an MPLAB® X project with an MPLAB Code Configurator (MCC) generated code example for an LED blink driven by a Pulse-width modulation (PWM) signal. The example demonstrates how to generate a PWM signal using a timer. The output waveform is connected to the on-board LED. The PWM duty cycle value is set at 50%. For half of the period the LED is turned ON, and for the other half the LED is turned OFF.
More details and code examples on the AVR128DA48 can be found at the following links:
- MPLAB X IDE v6.10 or newer
- MPLAB XC8 2.41 or newer
- AVR-Dx Device Family Pack v2.3.272 or newer
- AVR128DA48 Curiosity Nano Development Board is used as test platform:
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 configurations must be made for this project:
-
Clock Control:
-
Configuration Bits:
-
Interrupt Manager:
-
TCA1:
Pin | Configuration |
---|---|
PC6 (LED0) | Digital Output |
The demo shows how to generate a PWM signal using Timer/Counter Type A (TCA). The output of the TCA is connected to the on-board LED of the AVR128DA48 Curiosity Nano board and a waveform signal is generated.
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 theExample_Project.X
project and select Clean and Build. -
Select 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 OK -
Program the project to the board:
Right click on the project and then Make and Program Device.