Embedded-Knowledge

This channel provides basic to advance tutorial of IOT, ESP32 and ARM based controller.
You will get here Code and schematic diagram without any charges.


Embedded-Knowledge

We had been debugging for hours.
The system would freeze randomly. No crash. No logs. Justโ€ฆ dead silence.

Was it the hardware?
Was it power?
Race conditions?
ISR timing?


๐๐จ

Just a simple line like this:

๐’˜๐’‰๐’Š๐’๐’†(๐’‡๐’๐’‚๐’ˆ == 0);

And we forgot one keyword:
๐Ÿ‘‰ ๐•๐จ๐ฅ๐š๐ญ๐ข๐ฅ๐ž

The compiler optimized the check out.
It assumed the value of flag wouldnโ€™t change.

But it didโ€”inside an interrupt.
And we never told the compiler.

๐–๐ก๐š๐ญ ๐๐จ๐ž๐ฌ ๐‘ฝ๐’๐’๐’‚๐’•๐’Š๐’๐’† ๐ซ๐ž๐š๐ฅ๐ฅ๐ฒ ๐ฆ๐ž๐š๐ง?

It says:

"๐‘ป๐’‰๐’Š๐’” ๐’—๐’‚๐’“๐’Š๐’‚๐’ƒ๐’๐’† ๐’„๐’‚๐’ ๐’„๐’‰๐’‚๐’๐’ˆ๐’† ๐’‚๐’๐’š๐’•๐’Š๐’Ž๐’†. ๐‘ซ๐’๐’'๐’• ๐’‚๐’”๐’”๐’–๐’Ž๐’† ๐’‚๐’๐’š๐’•๐’‰๐’Š๐’๐’ˆ. ๐‘ฑ๐’–๐’”๐’• ๐’„๐’‰๐’†๐’„๐’Œ ๐’Š๐’• ๐’‚๐’”-๐’Š๐’”, ๐’‚๐’๐’˜๐’‚๐’š๐’”."


๐–๐ก๐ž๐ง ๐ฒ๐จ๐ฎ ๐Œ๐”๐’๐“ ๐ฎ๐ฌ๐ž ๐ฏ๐จ๐ฅ๐š๐ญ๐ข๐ฅ๐ž:

Variables updated in ISRs

Hardware register access

Shared flags between threads/tasks

DMA-updated memory

That one missing keyword cost us days of debugging.
It was a lesson for life.

7 months ago | [YT] | 1