Where to study stm32 / C for embedded / etc


I’d like to start a discussion about good sources/sites/tutorials/books about following topics (and put together some list of most interesting stuff):

  • learn some best practices for stm32 programming
  • learn about ARM Cortex architecture
  • some tutorials on C programming for embedded device
  • etc…

Please post your favorite blog posts, blogs, pages, tutorials,… or anything that helped you understand some of those topics better :slight_smile:


Speaking the ARM Cortex M0+ generally, I believe this book is a great start (and sort of a classic one): https://www.amazon.com/Definitive-Cortex®-M0-Cortex-M0-Processors-Second/dp/0128032774

Regarding the C for embedded - it is not really different from what you do on a desktop with the exception of dynamic memory allocation resource. You can still use heap, but often you will find out, that it is not a recommended practice and sometimes even forbidden. The main reason for that is reliability, since you cannot afford either memory leaks or memory fragmentation problems in deep embedded and memory constrained systems. Obviously, there are scenarios when the heap allocation might be inevitable, but one should use it carefully. You should also watch over the stack usage, since it is typically set to the size far below what you are used to in a fully-fledged environment.

Other aspects of embedded programming is interrupt invocation and processing. Interrupt is like second run context next to your main application. The interrupts might be invoked at any time if a particular source is enabled and if interrupts share some data access, you should lock it appropriately - for example by disabling the specific interrupt source, or disabling interrupts globally. If there is a polling on a variable state which may change in interrupt context, it is important to mark such variable as “volatile” because of the compilers optimizations. Otherwise the variable might not be re-evaluated on the physical memory address, but a register since compiler does not see any reason to change in a GIVEN CONTEXT. But interrupt is a different scope as explained earlier.

I want to point out you also have startup code which intiializes bss section and copies const area and jumps to your entry point (main function), often it also pre-configures clock subsystem and flash memory (number of wait states, etc.). It is your responsibility to manage sleep modes of the CPU, but this is where BigClown SDK does the job really well.

It is not much, but hopefully it will give you some headstart and feel free to ask anytime!