4.1 Atmel Studio with AVR128DA48 Curiosity Nano

Prerequisites

  • Atmel Studio 7.0.2397 or later installed
  • The AVR128DA48 Curiosity Nano 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

  1. Launch Atmel Studio 7.0.
  2. The page shown in Figure 4-1 will appear when AVR128DA48 Curiosity Nano is connected to Atmel Studio 7.0.
    Figure 4-1. AVR128DA48 Curiosity Nano Page in Atmel Studio
  3. Start creating a new project by clicking New → Project... or by using Ctrl+Shift+N shortcut, as shown in Figure 4-2.
    Figure 4-2. Create New Project in Atmel Studio
  4. Select the GCC C Executable Project template, as shown in Figure 4-3, 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
  5. Select AVR128DA48 from Figure 4-4, and click OK.
    Figure 4-4. Device Selection Wizard
    A new project with a main.c file associated with it will be generated in Atmel Studio.
  6. 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;
        }
      }
    }
    In the code editor, the code will appear, as shown in Figure 4-5.
    Figure 4-5. Code Editor Window
  7. Open project properties by clicking Project → Properties or by using ALT+F7 shortcut.
  8. In the Tool view (see Figure 4-6), set Selected debugger/programmer to nEDBG and Interface to UPDI.
    Figure 4-6. Debugger and Interface for AVR128DA48
  9. Build the project by clicking Build → Build Solution or by using F7 shortcut.
  10. Program AVR128DA48 with the project code and start debugging by clicking Debug → Start debugging and break or by using ALT+F5 shortcut . The application is programmed onto the device, and program execution will break in main() function.
  11. Run the code by clicking Debug → Continue or by using F5 shortcut .
  12. Verify that LED0 is lit when SW0 is pushed on the AVR128DA48 Curiosity Nano.