The ATmega4809 Xplained Pro board connected to Atmel Studio 7.0 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 Atmel Studio 7.0.
The page shown in the figure below will
appear when ATmega4809 Xplained Pro is connected to Atmel
Studio 7.0.Figure 4-1. ATmega4809 Xplained Pro Page in Atmel Studio
Start creating a new project by clicking
New → Project... or by using the shortcut Ctrl+Shift+N, as shown in
the following figure.Figure 4-2. Create New Project in Atmel
Studio
Select the GCC C Executable Project
template from the new project wizard shown in the figure below, type in the name of the
solution and project (e.g. GETTING_STARTED and LED_TOGGLE), and click
OK.Figure 4-3. New Project Wizard
Select ATmega4809 from the device selection wizard as shown in the
figure below, and click OK.Figure 4-4. Device Selection WizardA new project with a main.c file associated with it will be generated
in Atmel Studio.
Replace the 'main' loop in
the main.c file with the following code snippet:
int main (void)
{
/* Configure SW0 as input */
PORTB.DIRCLR = PIN2_bm;
/* Configure LED0 pin as output */
PORTB.DIRSET = PIN5_bm;
while (1)
{
/* Check the status of SW0 */
/* 0: Pressed */
if (!(PORTB.IN & (PIN2_bm)))
{
/* LED0 on */
PORTB.OUTSET = PIN5_bm;
}
/* 1: Released */
else
{
/* LED0 off */
PORTB.OUTCLR = PIN5_bm;
}
}
}
In the code editor, the code should appear
as shown in the figure below.Figure 4-5. Code Editor Window
Open project properties by clicking
Project → Properties or by using the shortcut ALT+F7.
In the Tool view (see the figure
below) set Selected debugger/programmer to EDBG and Interface to UPDI.Figure 4-6. Debugger and Interface for ATmega4809
Build the project by clicking Build →
Build Solution or by using the shortcut F7.
Program ATmega4809 with the project code and start
debugging by clicking Debug → Start debugging and break or by using the
shortcut ALT+F5. The application is programmed onto the device and program execution
should break in main.
Run the code by clicking Debug →
Continue or by using the shortcut F5).
Verify that LED0 is lit when SW0
is pushed on the ATmega4809 Xplained Pro.
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.