Debugging with Unified Program and Debug Interface (UPDI) for AVR® MCUs

Last modified by Microchip on 2024/06/24 06:30


The Unified Program and Debug Interface Physical Interface (UPDI PHY) provides programming and debugging through a 1-wire UART-based half-duplex interface using a single pin (either RESET or dedicated) for data reception and transmission.

In this example, an AVR® MCU supporting UPDI is used, i.e., ATtiny817. For more details about this device and its UPDI interface, see the ATtiny417 / ATtiny814 / ATtiny816 / ATtiny817 Datasheet.

The ATtiny817 Xplained Mini is used to demonstrate the UPDI interface. MPLAB® X IDE enables/disables this interface for you.

Back to top

Software and Hardware Used in this Example

For the best experience, install the following in order:

  1. ATtiny817 Xplained Mini
  2. MPLAB XC8 C Compiler v2.00 or higher
  3. MPLAB X IDE v5.10 or higher

Back to top

Creating a Project in the IDE

From the IDE, launch the New Project Wizard by selecting File > New Project.

Follow these steps to create a new project:

Choose Project: Select Microchip Embedded, and then select Standalone Project.

Select Device: Select the ATtiny817 device.

Select Header: None.

Select Tool: Select the ATtiny817 Xplained mini. Under Microchip Kits > ATtiny817 Xplained Mini (EDBG), find mEDBG and select SN: ATML….

Select Plugin Board: None.

Select Compiler: Select XC8 (v2.00) [bin location].

Select Project Name and Folder: Name the project, such as ATtiny817_UPDI.

Click Finish when done.

Back to top

Adding a File to the Project

Once a project is created, the Projects window will open.

Right-click on Source Files and select New > Other. Then choose Microchip Embedded > XC8 Compiler > avr-main.c.

Change the default name to from "avr-main.c" to "main.c".

Click Finish when done.

For this example, no additional code needs to be added to main.c.

Back to top

Debugging the Project

Click Debug Main Project debug-project.png  to start debugging.

During device programming, you may see this warning message:

Configuration memory will not be programmed because no configuration bits settings have been defined in your code. To program configuration memory, either define the settings in your code or use the Program Configuration Bits button on the configuration memory window.

For this example, no configuration bits settings were added to the code and no device configuration bits values were changed. For more on configuration bits, see the "Reading the Configuration Bits" section.

Programming proceeds and once complete, debug mode begins.

You are now in debug mode.

Click Pause pause.png to halt execution temporarily or Finish Debugger Session finish-debugger-session.png to end the debug session.

Back to top

Programming the Device

When you are done with debugging your code, you can program the target device by clicking Make and Program Device program-target-project.png.

Note for ​PIC® MCU Developers: A debug executive is not necessary for debugging with AVR MCUs. Therefore, programming for debug does not require different code.

Back to top

Reading the Configuration Bits

To set or clear device configuration bits (fuses), use the Configuration Bits window. Select Window > Target Memory Views > Configuration Bits.

When this window is first opened, all text is red and a pop-up message states that you must read the configuration bits from the device before you can edit.

AVR configuration bits

Click Read Configuration Bitsread-target-project.png on the window. The read should be successful and show this message in the mEDBF window:

Read complete

Data in the Configuration Bits window will be black and reflect the settings read from the device.

For this example, you have not changed any configuration bits. However, if you did want to change any bit values, you can write the new values to the device by clicking on Program Configuration Bits program-target-project.png .

Back to top

Learn More

Back to top