Atmel Studio with STK600

Prerequisites

Workflow

  1. 1.Launch Atmel Studio 7.0.
  2. 2.Start creating a new project by clicking New → Project... or by using the shortcut Ctrl+Shift+N, as shown in the figure below.
    Figure 1. Create New Project in Atmel Studio
  3. 3.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 2. New Project Wizard

  4. 4.Select ATtiny406 from the device selection wizard as shown in the figure below, and click OK.
    Figure 3. Device Selection Wizard

    A new project with a main.c file associated with it will be generated in Atmel Studio.
  5. 5.Replace the ‘main’ function in the main.c file with the following code snippet:
    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;
        }
      }
    }
    In the code editor, the code may appear as shown in the figure below.
    Figure 4. Code Editor Window
  6. 6.Open project properties by clicking Project → Properties or by using the shortcut ALT+F7.
  7. 7.In Tool view (figure below), set Selected debugger/programmer to STK600 and Interface to UPDI.
    Figure 5. Debugger and Interface for ATtiny406
  8. 8.Build the project by clicking Build → Build Solution or using the shortcut F7.
  9. 9.Connect the embedded debugger on STK600 to ATtiny406 by connecting a cable between the ISP/PDI headers, as shown in the figure below.
    Figure 6. UPDI Connection on STK600
  10. 10.Connect PB0 to SW0, and PB1 to LED0 by using cables.
  11. 11.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.
  12. 12.Run the code by clicking Debug → Continue or by using the shortcut F5.
  13. 13.Verify that LED0 is lit when SW0 is pushed on STK600.