|
| 1 | +--- |
| 2 | +title: 'Debugging the Arduino UNO R4 WiFi' |
| 3 | +description: 'Learn how to debug the UNO R4 WiFi.' |
| 4 | +tags: |
| 5 | + - Debugger |
| 6 | + - IDE |
| 7 | +author: 'Hannes Siebeneicher' |
| 8 | +--- |
| 9 | + |
| 10 | +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). |
| 11 | + |
| 12 | +In this context, debugging is a term used to describe the process of inspecting the code at different points in time. |
| 13 | + |
| 14 | +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. |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +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. |
| 19 | + |
| 20 | +## Goals |
| 21 | + |
| 22 | +The goals of this tutorial are: |
| 23 | + |
| 24 | +- learn about the basics of debugging. |
| 25 | +- learn how to set up the Arduino IDE to debug an Arduino sketch. |
| 26 | + |
| 27 | +## Hardware & Software Needed |
| 28 | + |
| 29 | +- [Arduino IDE](https://www.arduino.cc/en/main/software) |
| 30 | +- [Arduino UNO R4 WiFi](https://store.arduino.cc/uno-r4-wifi) |
| 31 | +- [UNO R4 Board Package](/tutorials/uno-r4-minima/minima-getting-started) |
| 32 | + |
| 33 | +## Debugging |
| 34 | + |
| 35 | +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. |
| 36 | + |
| 37 | +## Connection |
| 38 | + |
| 39 | +The only thing you need to do is to connect your UNO R4 WiFi to your computer using a USB-Cable. |
| 40 | + |
| 41 | +## Software |
| 42 | + |
| 43 | +### Setting up the Arduino IDE |
| 44 | + |
| 45 | +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. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +## Set correct Programmer |
| 50 | + |
| 51 | +To access and debug the mcu it's important that we set the correct programmer. Select **Tools** > **Programmer** > **ARM CMSIS-DAP compatible**. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +## Setting Breakpoints |
| 56 | + |
| 57 | +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. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +## Start Debugging |
| 62 | + |
| 63 | +Now you are ready to start debugging. Press "**Start Debugging**" next to the "Upload button" or click the icon in the left sidebar. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +You will see how your code is executed and **stopped** at the line you set the breakpoint. You can set as many breakpoints as you want, depending on where you want to stop your code. |
| 68 | + |
| 69 | +To resume the code press the "**Continue**" in the top left corner and you will see how the code runs until the it reaches the next breakpoint. |
| 70 | + |
| 71 | + |
0 commit comments