5.2 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

  1. Launch Atmel Studio 7.0.
  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 5-7. Create New Project in Atmel Studio
  3. 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 5-8. New Project Wizard
  4. Select ATtiny817 from the device selection wizard as shown in the figure below, and click OK.
    Figure 5-9. Device Selection Wizard
    A new project with a main.c file associated with it will be generated in Atmel Studio.
  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 should appear as shown in the figure below.
    Figure 5-10. Code Editor Window
  6. Open project properties by clicking Project → Properties or by using the shortcut ALT+F7.
  7. In the Tool view (see the figure below) set Selected debugger/programmer to STK600 and Interface to UPDI.
    Figure 5-11. Debugger and Interface for ATtiny817
  8. Build the project by clicking Build → Build Solution or using the shortcut F7.
  9. Connect the embedded debugger on STK600 to ATtiny817 by connecting a cable between the ISP/PDI headers, as shown in the figure below.
    Figure 5-12. UPDI Connection on STK600
  10. Connect PC5 to SW0, and PC0 to LED0 by using cables.
  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. Run the code by clicking Debug → Continue or by using the shortcut F5.
  13. Verify that LED0 is lit when SW0 is pushed on STK600.