Skip to content

Commit e9f34e0

Browse files
committed
Update tutorial content
1 parent bc18cc5 commit e9f34e0

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

content/learn/02.microcontrollers/04.debugging/debugging.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,15 @@ The Arduino® Zero board features an on-board debugger, the Atmel® Embedded Deb
154154

155155
![Arduino® Zero EDGB.](assets/debugging_img07.png)
156156

157-
Arduino® boards with a SAMD microcontroller feature native on-chip debug capabilities; these debugging capabilities can be used with an external ICD tool over JTAG or SWD interfaces. CMSIS-DAP compliant debug probes can be used with the Arduino IDE 2.0 out of the box without any configuration file; non-standard debug probes require a special configuration. Check out these tutorials to learn how to use an external ICD tool with SAMD based Arduino boards and the Arduino IDE 2.0:
157+
Arduino® boards with a SAMD microcontroller feature native on-chip debug capabilities; these debugging capabilities can be used with an external ICD tool over JTAG or SWD interfaces. **CMSIS-DAP compliant debug probes can be used with the Arduino IDE 2.0** out of the box without any configuration file; non-standard debug probes require a special configuration. Check out these tutorials to learn how to use an external ICD tool with SAMD based Arduino boards and the Arduino IDE 2.0:
158158

159159
* [Debugging with the SEGGER J-Link](https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup).
160160
* [Debugging with the Atmel-ICE](https://docs.arduino.cc/tutorials/mkr-wifi-1010/atmel-ice).
161161

162+
The [Arduino® Portenta H7](https://store.arduino.cc/products/portenta-h7), [H7 Lite](https://store.arduino.cc/products/portenta-h7-lite), and [H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) boards from the [Pro family](https://www.arduino.cc/pro) also support ICD debugging; these boards use the TRACE32 debugger from Lauterbach. The TRACE32 debugger allows testing embedded hardware and software by using the in-circuit debug interface of processors. Check out this tutorial to learn how to use the TRACE32 debugger with the Portenta family boards:
163+
164+
* [Lauterbach TRACE32 GDB Front-End Debugger for Portenta H7](https://docs.arduino.cc/tutorials/portenta-h7/por-ard-trace32).
165+
162166
### Hardware Tools
163167

164168
Embedded systems developers and typical software developers differ on a key aspect: their "closeness" to hardware; embedded system developers are usually closer to hardware than typical software developers. There are several tools that embedded systems developers use to find out what is going on with the hardware, which is very helpful for low-level software debugging. These tools are **multimeters**, **logic analyzers**, **oscilloscopes**, and **software-defined radios** (SDRs).
@@ -224,7 +228,7 @@ Shown visual representation of the signal via SDR software can now be used to ve
224228

225229
## Debugging Techniques Example
226230

227-
A simple example will demonstrate the implementation of different debugging techniques and how they can be handy for the development process of a program in the Arduino® ecosystem. We will use the Arduino® Nano 33 BLE Sense board, and its onboard inertial measurement unit (IMU) features to show the debugging process's importance. The example code uses accelerometer, gyroscope, and magnetometer data simultaneously, having the tasks be executed to obtain every value:
231+
A simple example will demonstrate the implementation of some of the debugging techniques we discussed before and how they can be handy for the development process of code in the Arduino® ecosystem. We will use the [Arduino® Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) board, and its onboard inertial measurement unit (IMU) features to show the debugging process's importance. The example code uses accelerometer, gyroscope, and magnetometer data simultaneously, having the tasks be executed to obtain every value:
228232

229233
```arduino
230234
/*
@@ -297,7 +301,7 @@ void accelerometer_task() {
297301
IMU.readAcceleration(x, y, z);
298302
good++;
299303
} else {
300-
Serial.println(F("Accelerometer data not ready"));
304+
Serial.println(F("- Accelerometer data not ready"));
301305
bad++;
302306
}
303307
@@ -337,7 +341,7 @@ void accelerometer_task() {
337341
}
338342
339343
// Gyroscope setup
340-
void gyroscope_setup(){
344+
void gyroscope_setup() {
341345
Serial.print(F("- Gyroscope sample rate = "));
342346
Serial.print(IMU.gyroscopeSampleRate());
343347
Serial.println(F(" Hz"));
@@ -346,7 +350,7 @@ void gyroscope_setup(){
346350
}
347351
348352
// Read gyroscope data in all three directions task
349-
void gyroscope_task(){
353+
void gyroscope_task( ) {
350354
if (IMU.gyroscopeAvailable()) {
351355
IMU.readGyroscope(x, y, z);
352356
Serial.println(F("- Gyroscope data ready"));
@@ -356,22 +360,22 @@ void gyroscope_task(){
356360
bad++;
357361
}
358362
359-
if(y > plusThreshold){
363+
if(y > plusThreshold) {
360364
Serial.println(F("- Collision front"));
361365
delay(500);
362366
}
363367
364-
if(y < minusThreshold){
368+
if(y < minusThreshold) {
365369
Serial.println(F("- Collision back"));
366370
delay(500);
367371
}
368372
369-
if(x < minusThreshold){
373+
if(x < minusThreshold) {
370374
Serial.println(F("- Collision right"));
371375
delay(500);
372376
}
373377
374-
if(x > plusThreshold){
378+
if(x > plusThreshold) {
375379
Serial.println(F("- Collision left"));
376380
delay(500);
377381
}
@@ -397,22 +401,22 @@ void save_debug_buffer(void) {
397401
if (count < DUMP_BUFFER_SIZE) {
398402
GoodBuffer[count] = good;
399403
BadBuffer[count] = bad;
400-
Disp_Debug_Buffer();
404+
disp_debug_buffer();
401405
count++;
402406
}
403407
}
404408
405-
void disp_debug_buffer(){
406-
// Simple log of Good or Bad Pass Marks during runtime
407-
Serial.println(F("\n Strategic Array Dump Result >>"));
408-
Serial.print(F("Good Marks: "));
409+
// Debugging array buffer
410+
void disp_debug_buffer() {
411+
Serial.println(F("\n Debugging array buffer result >>"));
412+
Serial.print(F("- Good marks: "));
409413
Serial.println(GoodBuffer[count]);
410414
411-
Serial.print(F("Bad Marks: "));
415+
Serial.print(F("- Bad marks: "));
412416
Serial.println(BadBuffer[count]);
413417
}
414418
415-
void debug_stop(){
419+
void debug_stop() {
416420
Serial.flush();
417421
exit(1);
418422
}
@@ -430,7 +434,7 @@ In the Arduino Serial Monitor, we can observe that it has a `1` good mark and a
430434

431435
The accelerometer performed its task without any issue except the first runtime instance, resulting in `9` good marks but `1` bad mark due to this behavior. The `Serial.println(F())` instruction of module setups and task runtimes also shows us if the code could get past the operations without any issue. By this, it is possible to know the code structure does not misbehave, but for the first time when the device is starting, the accelerometer requires more time to get the data ready in the first instance.
432436

433-
Additionally, it is possible to modify the loop code by simply adding a `digitalWrite(LED_BUILTIN, HIGH)` instruction and a `digitalWrite(LED_BUILTIN, LOW)` instruction to measure the time it takes to complete the three module tasks. It will also be helpful to understand the power consumption it draws from this runtime instance:
437+
Additionally, it is possible to modify the loop code by simply adding a `digitalWrite(LED_BUILTIN, HIGH)` instruction before tasks are called instruction and a `digitalWrite(LED_BUILTIN, LOW)` instruction after the tasks are exectued to measure the time it takes to complete them. This can also be helpful to understand the power consumption it draws from this runtime instance:
434438

435439
```arduino
436440
void loop() {
@@ -442,7 +446,7 @@ void loop() {
442446
digitalWrite(LED_BUILTIN, LOW);
443447
}
444448
445-
Save_Debug_Buffer();
449+
save_debug_buffer();
446450
447451
debug_stop();
448452
}
@@ -459,7 +463,7 @@ Debugging is a necessary step for developing robust and reliable embedded system
459463

460464
Knowing the potential causes of bugs allows us to adopt strategies that minimize their occurrence. Many different debugging techniques and external devices are present to aid this process. Maybe some software designs do not require the usage of external debuggers, for example. However, when the software involves different requirements, especially scalability, things change drastically for the development process. The debugging techniques and the external debuggers will support this development process, thus granting sophisticated software. In most cases, we will know how the device will behave with the software, its computational performance, and even achieve non-power hungry devices due to clean memory management.
461465

462-
Debugging may be an overlooked aspect of development, but it is the most serious yet crucial tool for development. If we desire to develop a robust and reliable device, the debugging process should consistently be implemented to achieve this goals.
466+
Debugging may be an overlooked aspect in developing embedded systems, but it is its most serious yet crucial tool. If we desire to develop robust and reliable embedded systems, the debugging process should consistently be implemented to achieve these goals.
463467

464468
## Further Reading and Resources
465469

0 commit comments

Comments
 (0)