Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Karl Söderby <[email protected]>
  • Loading branch information
Hannes7eicher and karlsoderby authored Dec 16, 2024
1 parent 662d5e5 commit be22fbe
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
---
title: 'Debugging the Arduino UNO R4 WiFi'
description: 'Learn how to debug the UNO R4 WiFi.'
description: 'Learn how to debug the UNO R4 WiFi with the Arduino IDE.'
tags:
- Debugger
- IDE
author: 'Hannes Siebeneicher'
---

Debugging is the process of identifying and fixing errors in your code. It’s a vital skill for anyone writing code especially when dealing with microcontrollers like those on your Arduino. As with everything, debugging can be done at different levels, you can read up on the topic [here](/learn/microcontrollers/debugging).
Debugging is the process of identifying and fixing errors in your code. It’s a vital skill for anyone writing code especially when dealing with microcontrollers like those on your Arduino.

In this context, debugging is a term used to describe the process of inspecting the code at different points in time.
In this article, we will focus on using the Arduino IDE's built-in debugger, which can be used to debug the UNO R4 WiFi over USB. We will go through how to:
- Enable debugging mode in the Arduino IDE
- Create breakpoints for where we want to inspect the code
- Monitor the value of a variable at a specific point in the program

An analogy that is often used is to think of it as "stepping into" the code, grabbing full control of the clock and walking through it line by line, checking the value of variables as you go, and reading specific memory addresses to make sure information is being passed on as intended.
Note that you **do not** need an external debugger to follow this tutorial.

This is especially helpful when creating complex projects, but even as a beginner, it can be helpful to know the basics of debugging, consequently saving you time and energy when trying to find the little annoying error causing your program to break down.

This article covers the basic steps for debugging the UNO R4 WiFi using the IDE, such as setting breakpoints. A breakpoint is an intentional stopping or pausing place at a specific point in the code, allowing you to read values at that exact point. In this case, we will be using the Arduino IDE which we can use to set breakpoints, read out memory addresses, and read the value of any variable at a specific point in time.
***To learn more about general debugging principles, you can read up on the topic [here](/learn/microcontrollers/debugging).***

## Goals

Expand All @@ -32,7 +33,7 @@ The goals of this tutorial are:

## Debugging

Debugging your Arduino project allows you to dive deep into your code and troubleshoot as well as analyze the code execution. Yu can gain full access to the microcontroller's internal registers, memory, and variables. This is especially helpful when working on more complex projects where understanding the code execution flow is crucial. With the Arduino IDE you can step through the code line by line, allowing you to analyze why your code might break at a specific point.
Debugging your Arduino project allows you to dive deep into your code and troubleshoot as well as analyze the code execution. You can gain full access to the microcontroller's internal registers, memory, and variables. This is especially helpful when working on more complex projects where understanding the code execution flow is crucial. With the Arduino IDE you can step through the code line by line, allowing you to analyze why your code might break at a specific point.

## Connection

Expand All @@ -42,19 +43,19 @@ The only thing you need to do is to connect your UNO R4 WiFi to your computer us

### Setting up the Arduino IDE

First, if you haven't done it yet, install the [Arduino IDE](https://www.arduino.cc/en/software). It's a good ieda to verify that everything is working as it should by uploading the Blink example.
First, if you haven't done it yet, install the [Arduino IDE](https://www.arduino.cc/en/software). It's a good idea to verify that everything is working as it should by uploading the Blink example.

![Blink Example](./assets/blink_example.png)

## Set Correct Programmer

To access and debug the mcu it's important that we set the correct programmer. Select **Tools** > **Programmer** > **ARM CMSIS-DAP compatible**.
To access and debug the Arduino's MCU it's important that we set the correct programmer. Select **Tools** > **Programmer** > **ARM CMSIS-DAP compatible**.

![Set Programmer](./assets/set_programmer.png)

## Setting Breakpoints

As mentioned above a breakpoint is an intentional stopping or pausing place at a specific point in the code. You can add them by clicking the sidebar next to your sketch, and you should see a red dot appear. You have now set a breakpoint.
A breakpoint is an intentional stopping or pausing place at a specific point in the code. You can add them by clicking the sidebar next to your sketch, and you should see a red dot appear. You have now set a breakpoint.

![Setting a breakpoint](./assets/set_breakpoints.png)

Expand Down

0 comments on commit be22fbe

Please sign in to comment.