4.1 Atmel Studio with STK600
Prerequisites
- Atmel Studio 7.0 1645 or above installed
 - The STK600 board connected to Atmel Studio 7.0 via the on-board USB connector.
 
Workflow
- Launch Atmel Studio 7.0.
 - Start creating a new project by clicking
            New → Project... or by using the shortcut Ctrl+Shift+N, as shown in
        the figure below.
Figure 4-1. Create New Project in Atmel Studio 
         - Select the GCC C Executable Project
        template from the new project wizard shown in the following figure, type in the name of the
        solution and project (e.g. GETTING_STARTED and LED_TOGGLE), and click
          OK.
Figure 4-2. New Project Wizard 
         - Select ATtiny406 from the device selection wizard as shown in the
        figure below, and click OK.
Figure 4-3. Device Selection Wizard 
        
A new project with amain.cfile associated with it will be generated in Atmel Studio. - Replace the ‘
main’ function in themain.cfile with the following code snippet:
In the code editor, the code may appear as shown in the figure below.int main (void) { /* STK600 have eight User Buttons and eight User LEDs which can be connected to any IO pin using cables */ /* Configure PB0 as input (remember to connect SW0 to PB0 using a cable */ PORTB.DIRCLR = PIN0_bm; /* Configure PB1 as output (remember to connect LED0 to PB1 using a cable*/ PORTB.DIRSET = PIN1_bm; while (1) { /* Check the status of SW0 */ /* 0: Pressed */ if (!(PORTB.IN & (PIN0_bm))) { /* LED0 on */ PORTB.OUTCLR = PIN1_bm; } /* 1: Released */ else { /* LED0 off */ PORTB.OUTSET = PIN1_bm; } } }Figure 4-4. Code Editor Window 
         - Open project properties by clicking Project → Properties or by using the shortcut ALT+F7.
 - In Tool view (figure below), set
          Selected debugger/programmer to STK600 and Interface to UPDI.
Figure 4-5. Debugger and Interface for ATtiny406 
         - Build the project by clicking Build → Build Solution or using the shortcut F7.
 - Connect the embedded debugger on STK600 to ATtiny406 by connecting a cable between the ISP/PDI headers,
        as shown in the figure below.
Figure 4-6. UPDI Connection on STK600 
         - Connect PB0 to SW0, and PB1 to LED0 by using cables.
 - Load the code onto the STK600 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 the 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 STK600.
 
