https://itp.nyu.edu/classes/prototypingelectronicdevices/wp-content/uploads/sites/105/2022/11/Class-10-Debugging-Arduino.pdf
<aside> <img src="/icons/bug_gray.svg" alt="/icons/bug_gray.svg" width="40px" />
Debugger
Logic analyzer brand: Saleae , or it’s clone, which is much cheaper
For Arduino UNO, RST has to be cut to connect to debug board, this is because the RST includes a lot of capacitor, which might absorb the high speed signal sent from the debug board

“asm” is a way to hack the complier and make sure that the code is run in a way that is easy to debug. Complier intents to speed up the code, so the a=1 might actually happen after delay(100) in machine’s code, without being known by the user end. Thus, in the below code, asm(”nap”); make sure that the compiler stop the operation stops, and the debugger can work as expected.

The optimizer in complier would actually want to optimize the speed when assembling the code, by either neglecting or jumping through the code. If “volatile” is not used, in circumstances that the parameters aren’t used further down in the code, the parameters wouldn’t actually be put into register, thus not visible for the debugger. Putting volatile in the code is like saying “don’t try to optimize and skip stuff”
Call stack in the debugger panel shows the layer of the function, for instance, the current function I’m in is main—>loop—>testSimpleAdd. This function is useful in navigating ourselves in the code structure.

**smd test clip** can be handy for quick debug process
</aside>
<aside> <img src="/icons/art_gray.svg" alt="/icons/art_gray.svg" width="40px" />
RAM Structure

The above image includes 3 main parts of the RAM (dynamic memory)
Static Data: memorize all the global variable.
Stack and Heap: both utilizing the free memory. They are the memory used during the operation of code. The key difference is that “heap” is actually manually assigned using malloc function. The risk of heap is that, when one parameter is assigned to a definite spot in the free memory, after it’s used, the spot is still occupied and create “hole” in the free memory.
For the “dynamic memory” calculated in the console after an Arduino code is uploaded on the board, it’s only for the static data part.
</aside>