MPLAB® X with ATtiny1627 Curiosity Nano

Prerequisites

Workflow

  1. 1.Launch MPLAB X.
  2. 2.The page shown in Figure 1 will appear when ATtiny1627 Curiosity Nano is connected to MPLAB X.
    Figure 1. ATtiny1627 Curiosity Nano Page in MPLAB® X
  3. 3.Start creating a new project by clicking File → New Project... or by using the Ctrl+Shift+N shortcut, as shown in Figure 2.
    Figure 2. Create New Project in MPLAB® X
  4. 4.Select the Categories → Microchip Embedded and Projects → Standalone Project template from Figure 6, and click Next.
    Figure 3. New Project Window
  5. 5.Select ATtiny1627 (see Figure 4) and click Next.
    Figure 4. Device Selection Window
    Then select the board and the desired compiler, if there are any.
  6. 6.Type in the name of the project (e.g., LED_TOGGLE) and the project location (e.g., C:\microchip), and click Finish.
    Figure 5. Project Name and Location Selection Window
  7. 7.Create a new main.c file by clicking File → New File... or by using Ctrl+N shortcut, as shown in Figure 6.
    Figure 6. Create a New File in MPLAB® X
  8. 8.Select the Categories → C and File Types → C Main File template from Figure 7, and click Next.
    Figure 7. New File Window
  9. 9.Type in the name of the file (e.g., main) and click Finish.
    Figure 8. File Name Window
  10. 10.Replace the main.c file with the following code snippet:
    int main (void)
    {
      /* Configure SW0 as input */
      PORTC.DIRCLR = PIN4_bm;
      /*Enable internal pull up for SW0*/
      PORTC.PIN4CTRL  = PORT_PULLUPEN_bm; 
      /* Configure LED0 pin as output */
      PORTB.DIRSET = PIN7_bm;
    	
      while (1)
      {
        /* Check the status of SW0 */
        /* 0: Pressed */
        if (!(PORTC.IN & (PIN4_bm)))
        {
          /* LED0  off */
          PORTB.OUTSET = PIN7_bm;
        }
        /* 1: Released */
        else
        {
          /* LED0 on */
          PORTB.OUTCLR = PIN7_bm;
        }
      }
    }
    Add #inlude<avr/io.h> in main.c. In the code editor, the code will appear as shown in Figure 9.
    Figure 9. Code Editor Window
  11. 11.Build the code by clicking on Production → Clean and Build Main Project or by using the Shift + F11 shortcut.
  12. 12.Program ATtiny1627 with the project code and start debugging by clicking Debug → Debugging Main Project.
  13. 13.Verify that LED0 is lit when SW0 is pushed on the ATtiny1627 Curiosity Nano.