5.1 MPLAB® X with AVR128DA48 Curiosity Nano
Prerequisites
- MPLAB X installed
- The AVR128DA48 Curiosity Nano Board connected to MPLAB X via the on-board USB connector, which is connected to the embedded debugger. The kit will be powered by the USB, and the embedded debugger will enable debugging and programming via the USB.
Workflow
- Launch MPLAB X.
- The page shown in Figure 5-1 will appear when AVR128DA48 Curiosity Nano is connected to MPLAB X.
- Start creating a new project by clicking File → New Project... or by using Ctrl+Shift+N shortcut, as shown in Figure 5-2.
- Select the Categories → Microchip Embedded and Projects → Standalone Project template from Figure 5-6, and click Next.
- Select AVR128DA48 from Figure 5-4, and click Next.Then select the board and the desired compiler, if there are any.
- Type in the name of the project (e.g., LED_TOGGLE) and the project location (e.g., C:\microchip), and click Finish.
- Create a new
main.c
file by clicking File → New File... or by using Ctrl+N shortcut, as shown in Figure 5-6. - Select the Categories → C and File Types → C Main File template from Figure 5-7, and click Next.
- Type in the name of the file (e.g., main) and click Finish.
- Replace the
main.c
file with the following code snippet:int main (void) { /* Configure SW0 as input */ PORTC.DIRCLR = PIN7_bm; /* Configure LED0 pin as output */ PORTC.DIRSET = PIN6_bm; /* Enable the internal pull-up for SW0 */ PORTC.PIN7CTRL |= PORT_PULLUPEN_bm; while (1) { /* Check the status of SW0 */ /* 0: Pressed */ if (!(PORTC.IN & (PIN7_bm))) { /* LED0 on */ PORTC.OUTSET = PIN6_bm; } /* 1: Released */ else { /* LED0 off */ PORTC.OUTCLR = PIN6_bm; } } }
- Build the code by clicking on Production → Clean and Build Main Project or by using Shift + F11 shortcut.
- Program AVR128DA48 with the project code and start debugging by clicking Debug → Debugging Main Project.
- Verify that LED0 is lit when SW0 is pushed on the AVR128DA48 Curiosity Nano.