Skip to content

Commit 8caedb7

Browse files
committed
Merge branch 'main' into content/micropython/micropython-revamp
2 parents a547cb7 + ab4ec7b commit 8caedb7

File tree

18 files changed

+111
-6
lines changed

18 files changed

+111
-6
lines changed
Loading
Loading
Loading
Loading
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: 'Debugging the Arduino UNO R4 WiFi'
3+
description: 'Learn how to debug the UNO R4 WiFi with the Arduino IDE.'
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.
11+
12+
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:
13+
- Enable debugging mode in the Arduino IDE
14+
- Create breakpoints for where we want to inspect the code
15+
- Monitor the value of a variable at a specific point in the program
16+
17+
Note that you **do not** need an external debugger to follow this tutorial.
18+
19+
***To learn more about general debugging principles, you can read up on the topic [here](/learn/microcontrollers/debugging).***
20+
21+
## Goals
22+
23+
The goals of this tutorial are:
24+
25+
- learn about the basics of debugging.
26+
- learn how to set up the Arduino IDE to debug an Arduino sketch.
27+
28+
## Hardware & Software Needed
29+
30+
- [Arduino IDE](https://www.arduino.cc/en/main/software)
31+
- [Arduino UNO R4 WiFi](https://store.arduino.cc/uno-r4-wifi)
32+
- [UNO R4 Board Package](/tutorials/uno-r4-minima/minima-getting-started)
33+
34+
## Debugging
35+
36+
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.
37+
38+
## Connection
39+
40+
The only thing you need to do is to connect your UNO R4 WiFi to your computer using a USB-Cable.
41+
42+
## Software
43+
44+
### Setting up the Arduino IDE
45+
46+
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.
47+
48+
![Blink Example](./assets/blink_example.png)
49+
50+
## Set Correct Programmer
51+
52+
To access and debug the Arduino's MCU it's important that we set the correct programmer. Select **Tools** > **Programmer** > **ARM CMSIS-DAP compatible**.
53+
54+
![Set Programmer](./assets/set_programmer.png)
55+
56+
## Setting Breakpoints
57+
58+
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.
59+
60+
![Setting a breakpoint](./assets/set_breakpoints.png)
61+
62+
## Start Debugging
63+
64+
Now you are ready to start debugging. Press "**Start Debugging**" next to the "Upload button" or click the icon in the left sidebar.
65+
66+
![Start Debugging](./assets/start_debugger.png)
67+
68+
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.
69+
70+
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.
71+
72+
![Resume Code](./assets/resume_code.png)
Loading

content/hardware/02.hero/boards/uno-r4-wifi/tutorials/eeprom/eeprom.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The goals of this tutorials are:
2626

2727
## EEPROM
2828

29-
Electronically erasable programmable read-only memory (EEPROM) is a memory that can be used to store data that can be retrieved after power loss. This memory can be effective to use during run-time to log data can be used to re-initialize whenever a system comes back online.
29+
Electronically erasable programmable read-only memory (EEPROM) is a memory that can be used to store data that can be retrieved after power loss - it is non-volatile. EEPROM memory can be useful during run-time to log data, or can be used to re-initialize variables whenever a system comes back online.
3030

3131
When writing to the EEPROM memory, we specify two parameters: the **address** and **value**. Each byte can hold a value between 0-255.
3232

@@ -90,4 +90,4 @@ void loop() {
9090

9191
## Summary
9292

93-
In this tutorial, you've learned how to access the EEPROM on the UNO R4 WiFi board. To learn more about EEPROM, visit [A Guide to EEPROM](https://docs.arduino.cc/learn/programming/eeprom-guide).
93+
In this tutorial, you've learned how to access the EEPROM on the UNO R4 WiFi board. To learn more about EEPROM, visit [A Guide to EEPROM](https://docs.arduino.cc/learn/programming/eeprom-guide).

content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-usb/giga-usb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void setup() {
277277
278278
msd.connect();
279279
280-
while (!msd.connected()) {
280+
while (!msd.connect()) {
281281
//while (!port.connected()) {
282282
delay(1000);
283283
}
@@ -358,7 +358,7 @@ void setup() {
358358
359359
msd.connect();
360360
361-
while (!msd.connected()) {
361+
while (!msd.connect()) {
362362
Serial.print("MSD not found.");
363363
delay(1000);
364364
}

content/hardware/10.mega/shields/giga-display-shield/tutorials/02.gfx-guide/gfx-guide.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ To use the library, we simply need to create a display object, initialize the li
4343
GigaDisplay_GFX display; // create the object
4444
4545
void setup() {
46+
delay(3000);
4647
display.begin(); //init library
4748
4849
display.setCursor(10,10); //x,y
@@ -97,6 +98,7 @@ GigaDisplay_GFX display; // create the object
9798
#define BLACK 0x0000
9899
99100
void setup() {
101+
delay(3000);
100102
display.begin();
101103
display.fillScreen(BLACK);
102104
display.setCursor(10,10); //x,y
@@ -131,6 +133,7 @@ GigaDisplay_GFX display;
131133
#define BLACK 0x0000
132134
133135
void setup() {
136+
delay(3000);
134137
display.begin();
135138
display.fillScreen(WHITE);
136139
display.drawTriangle(100, 200, 300, 400, 300, 600, BLACK);
@@ -173,6 +176,7 @@ int counter;
173176
void setup() {
174177
// put your setup code here, to run once:
175178
Serial.begin(9600);
179+
delay(3000);
176180
display.begin();
177181
178182
if (touchDetector.begin()) {

content/hardware/10.mega/shields/giga-display-shield/tutorials/03.lvgl-guide/content.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ In the `setup()`, we begin by initializing the display and the touch detector.
6464

6565
```arduino
6666
void setup(){
67+
delay(3000);
6768
Display.begin();
6869
TouchDetector.begin();
6970
}
@@ -154,6 +155,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
154155
Arduino_GigaDisplayTouch TouchDetector;
155156
156157
void setup() {
158+
delay(3000);
157159
Display.begin();
158160
TouchDetector.begin();
159161
@@ -236,6 +238,7 @@ To make sure we see the image use the align function to make it centered. Then a
236238
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
237239
238240
void setup() {
241+
delay(3000);
239242
Display.begin();
240243
241244
lv_obj_t * screen = lv_obj_create(lv_scr_act());
@@ -335,6 +338,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
335338
Arduino_GigaDisplayTouch TouchDetector;
336339
337340
void setup() {
341+
delay(3000);
338342
Display.begin();
339343
TouchDetector.begin();
340344
@@ -410,6 +414,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
410414
Arduino_GigaDisplayTouch TouchDetector;
411415
412416
void setup() {
417+
delay(3000);
413418
Display.begin();
414419
TouchDetector.begin();
415420
@@ -506,6 +511,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield); /* Arduino_H7_Vi
506511
Arduino_GigaDisplayTouch TouchDetector;
507512
508513
void setup() {
514+
delay(3000);
509515
Display.begin();
510516
TouchDetector.begin();
511517
@@ -634,6 +640,7 @@ static void set_slider_val(void * bar, int32_t val) {
634640
}
635641
636642
void setup() {
643+
delay(3000);
637644
Display.begin();
638645
TouchDetector.begin();
639646
@@ -752,6 +759,7 @@ static void btn_event_cb(lv_event_t * e) {
752759
}
753760
754761
void setup() {
762+
delay(3000);
755763
Display.begin();
756764
TouchDetector.begin();
757765

content/hardware/10.mega/shields/giga-display-shield/tutorials/04.basic-draw-and-image/content.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Let's first draw the background of the image. Start by initializing the display
4242

4343
```arduino
4444
void setup() {
45+
delay(3000);
4546
Display.begin();
4647
4748
Display.beginDraw();
@@ -97,6 +98,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
9798
//Arduino_H7_Video Display(1024, 768, USBCVideo);
9899
99100
void setup() {
101+
delay(3000);
100102
Display.begin();
101103
102104
Display.beginDraw();
@@ -193,6 +195,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
193195
Image img_arduinologo(ENCODING_RGB16, (uint8_t *) texture_raw, 300, 300);
194196
195197
void setup() {
198+
delay(3000);
196199
Display.begin();
197200
198201
Display.beginDraw();

content/hardware/10.mega/shields/giga-display-shield/tutorials/05.basic-touch/basic-touch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int lastTouch;
8585
int threshold = 250; //time in milliseconds
8686
8787
void setup() {
88+
delay(3000);
8889
Serial.begin(115200);
8990
while(!Serial) {}
9091
@@ -147,6 +148,7 @@ int threshold = 250;
147148
bool switch_1;
148149
149150
void setup() {
151+
delay(3000);
150152
// put your setup code here, to run once:
151153
Serial.begin(9600);
152154
display.begin();

content/hardware/10.mega/shields/giga-display-shield/tutorials/06.image-orientation/content.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ BoschSensorClass imu(Wire1);
3333

3434
Start receiving IMU readings with `imu.begin();` and start the display with `Display.begin();`.
3535

36-
Then we can assign attributes to the images such as its source, alignment and how the rotation should behave. For more information on image attributes with LVGL, check out our [LVGL tutorial](lvgl-guide#image).
36+
Then we can assign attributes to the images such as its source, alignment and how the rotation should behave. For more information on image attributes with LVGL, check out our [LVGL tutorial](/tutorials/giga-display-shield/lvgl-guide).
3737

3838
```arduino
3939
LV_IMG_DECLARE(img_arduinologo);
4040
lv_obj_t * img;
4141
4242
void setup() {
43+
delay(3000);
4344
Serial.begin(115200);
4445
4546
Display.begin();
@@ -91,6 +92,7 @@ The easiest way to tell what values you are getting depending on the orientation
9192
BoschSensorClass imu(Wire1);
9293
9394
void setup(){
95+
delay(3000);
9496
Serial.begin(115200);
9597
imu.begin();
9698
}
@@ -131,6 +133,7 @@ LV_IMG_DECLARE(img_arduinologo);
131133
lv_obj_t * img;
132134
133135
void setup() {
136+
delay(3000);
134137
Serial.begin(115200);
135138
136139
Display.begin();
@@ -176,4 +179,4 @@ Now try rotating your device to see if the image behaves correctly. If the image
176179

177180
## Conclusion
178181

179-
Now you know how to use the GIGA Display Shield's IMU sensor to gather readings for device orientation, and how to use these readings to make an image on the GIGA Display Shield maintain the correct orientation depending on what way it is facing.
182+
Now you know how to use the GIGA Display Shield's IMU sensor to gather readings for device orientation, and how to use these readings to make an image on the GIGA Display Shield maintain the correct orientation depending on what way it is facing.

content/hardware/10.mega/shields/giga-display-shield/tutorials/07.microphone-tutorial/content.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ short sampleBuffer[512];
209209
volatile int samplesRead;
210210
211211
void setup() {
212+
delay(3000);
212213
Display.begin();
213214
Display.beginDraw();
214215
Display.background(255, 255, 255);
@@ -316,6 +317,7 @@ lv_anim_t a;
316317
int micValue;
317318
318319
void setup() {
320+
delay(3000);
319321
Display.begin();
320322
321323
PDM.onReceive(onPDMdata);

content/hardware/10.mega/shields/giga-display-shield/tutorials/08.camera-tutorial/content.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void blinkLED(uint32_t count = 0xFFFFFFFF)
113113
uint32_t palette[256];
114114
115115
void setup() {
116+
delay(3000);
116117
// Init the cam QVGA, 30FPS
117118
if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) {
118119
blinkLED();

content/hardware/10.mega/shields/giga-display-shield/tutorials/10.square-line-tutorial/content.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield);
6262
Arduino_GigaDisplayTouch Touch;
6363
6464
void setup() {
65+
delay(3000);
6566
Display.begin();
6667
Touch.begin();
6768
@@ -119,6 +120,7 @@ Then it is as simple as using the names of the widgets in a LVGL function. For e
119120

120121
```arduino
121122
void setup() {
123+
delay(3000);
122124
Display.begin();
123125
Touch.begin();
124126
@@ -182,6 +184,7 @@ static void ButtonDec_evt_handler(lv_event_t * e) {
182184
}
183185
184186
void setup() {
187+
delay(3000);
185188
Display.begin();
186189
Touch.begin();
187190

content/hardware/10.mega/shields/giga-display-shield/tutorials/12.emwin-guide/content.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ When creating elements, information about the screen and placement needs to be p
5252

5353
```arduino
5454
void setup() {
55+
delay(3000);
5556
/* Init SEGGER emWin library. It also init display and touch controller */
5657
GUI_Init();
5758
@@ -73,6 +74,7 @@ Here is an example that sets the screen background color to green and prints the
7374
#include <DIALOG.h>
7475
7576
void setup() {
77+
delay(3000);
7678
GUI_Init();
7779
GUI_MULTIBUF_Begin();
7880
GUI_SetBkColor(GUI_GREEN);
@@ -261,6 +263,7 @@ static void _cbWin(WM_MESSAGE * pMsg) {
261263
}
262264
263265
void setup() {
266+
delay(3000);
264267
GUI_Init();
265268
WM_MULTIBUF_Enable(1);
266269
WM_CreateWindowAsChild(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_HBKWIN, WM_CF_SHOW, _cbWin, 0);
@@ -358,6 +361,7 @@ static void _cbChildWinCheck(WM_MESSAGE * pMsg) {
358361
}
359362
360363
void setup() {
364+
delay(3000);
361365
/* Init SEGGER emWin library. It also init display and touch controller */
362366
GUI_Init();
363367
@@ -469,6 +473,7 @@ static void _cbChildWinSlider(WM_MESSAGE * pMsg) {
469473
}
470474
471475
void setup() {
476+
delay(3000);
472477
/* Init SEGGER emWin library. It also init display and touch controller */
473478
GUI_Init();
474479
@@ -608,6 +613,7 @@ int progbarCnt = 0;
608613
unsigned long previousMillis = 0;
609614
610615
void setup() {
616+
delay(3000);
611617
/* Init SEGGER emWin library. It also init display and touch controller */
612618
GUI_Init();
613619
@@ -732,6 +738,7 @@ static void _cbChildWinBtn(WM_MESSAGE * pMsg) {
732738
}
733739
734740
void setup() {
741+
delay(3000);
735742
/* Init SEGGER emWin library. It also init display and touch controller */
736743
GUI_Init();
737744

0 commit comments

Comments
 (0)