EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1420 background imageLoading...
Page #1420 background image
Chapter 4. API Guides
For more information, see ESP32-S2 Technical Reference Manual > IO MUX and GPIO Matrix (GPIO, IO_MUX)
[PDF].
Being in the same blink.c project as before, set two breakpoints right after gpio_set_level instruction. Enter
two times c to get to the break point followed by x /1wx 0x3FF44004 to display contents of GPIO_OUT_REG
memory location:
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400DB75E (active) APP_CPU: PC=0x400D1128
Target halted. PRO_CPU: PC=0x400DB74E (active) APP_CPU: PC=0x400D1128
Breakpoint 2, blink_task (pvParameter=0x0) at /home/user-name/esp/blink/main/./
,blink.c:34
34 vTaskDelay(1000 / portTICK_PERIOD_MS);
(gdb) x /1wx 0x3FF44004
0x3ff44004: 0x00000000
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400DB751 (active) APP_CPU: PC=0x400D1128
Target halted. PRO_CPU: PC=0x400DB75B (active) APP_CPU: PC=0x400D1128
Breakpoint 3, blink_task (pvParameter=0x0) at /home/user-name/esp/blink/main/./
,blink.c:37
37 vTaskDelay(1000 / portTICK_PERIOD_MS);
(gdb) x /1wx 0x3FF44004
0x3ff44004: 0x00000010
(gdb)
If your are blinking LED connected to GPIO4, then you should see fourth bit being flipped each time the LED
changes the state:
0x3ff44004: 0x00000000
...
0x3ff44004: 0x00000010
Now, when the LED is off, that corresponds to 0x3ff44004: 0x00000000 being displayed, try using set
command to set this bit by writting 0x00000010 to the same memory location:
(gdb) x /1wx 0x3FF44004
0x3ff44004: 0x00000000
(gdb) set {unsigned int}0x3FF44004=0x000010
You should see the LED to turn on immediately after entering set {unsigned
int}0x3FF44004=0x000010 command.
Watching and setting program variables A common debugging tasks is checking the value of a program variable
as the program runs. To be able to demonstrate this functionality, update file blink.c by adding a declaration of
a global variable int i above definition of function blink_task. Then add i++ inside while(1) of this
function to get i incremented on each blink.
Exit debugger, so it is not confused with new code, build and flash the code to the ESP and restart debugger. There
is no need to restart OpenOCD.
Once application is halted, enter the command watch i:
(gdb) watch i
Hardware watchpoint 2: i
(gdb)
This will insert so called watchpointin each place of code where variable i is being modified. Now enter
continue to resume the application and observe it being halted:
Espressif Systems 1409
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish