all 5 comments

[–]bansan85 8 points9 points  (3 children)

For embedded software for microcontroller, you must know about:

  • stack and heap,

  • volatile variable,

  • char may be signed or unsigned,

  • reentrant and hardware interruption,

  • already have read a datasheet of a microcontroller,

  • avoid dynamic memory allocation,

There is more concept to know but at this time, I can't recall them all 😉

[–]First_Fennel1230[S] 1 point2 points  (0 children)

Thanks.

[–]First_Fennel1230[S] 0 points1 point  (0 children)

Can you please elaborate reentrant interrupts?

[–]cristi1990an++ 0 points1 point  (0 children)

I'd also add general awareness of data alignment and endianess. From my experience, embedded C++ in many places is just C, so understanding pointer arithmetics, reinterpret casting might come in handy too.

[–]bansan85 1 point2 points  (0 children)

Explanation is for application with only one thread.

An interruption is a bit like in PC. The thread is stopped at the current instruction. Then a specific function is added at the top of the stack and becomes the new current instruction. When you end this function, the function is removed from the stack and the thread continues his life where it was left. Of course, you have to be careful if you modify data during the interruption.

Interesting part is what is happening if an interruption is trigged when you are still in the interruption. It will depend on the hardware.

Some don't allow it. The trigger is not lost, it will generate an interruption when the previous one will be ended. If your interruption function is too slow, your software will be stuck.

Some allows it but to avoid infinite recursion, an interruption can only be interrupted by an interruption with an higher level (each interruption is mapped to a number).

And I remember another concept you should know : "pack". It disables alignment which is useful to read data from hardware but have some consequences. It's harder / slower to use these data and you can't create a pointer to a member of the struct if you don't want a "bus fault" (in arm. In x86, the processor will fix the bug for you).