Category: Tutorials

Tutorial – Jump to system memory from software on STM32 1

Tutorial – Jump to system memory from software on STM32

One of you are already familiar with STM32 feature of embedded bootloader for software download to flash. This memory is called system memory and is normally accessible with BOOT configuration (either pin hardware or option bytes (later OB) in flash software). Normally, if you want to jump to system memory, you have to setup pin/OB and reset device. If you have OB setup, this is ok, but since you need at least one BOOT pin in hardware, this can lead to hardware...

How to use scanf with USART 3

How to use scanf with USART

I’ve already posted how to use printf (send data to stream) on STM32Fxxx devices. Recently, I received a comment, how to use scanf function to read strings and convert them from USART. Here is a little bit more to do before it will work correct. When you call scanf function, it calls subfunction fgetc, where you return a character. This function is called until it does not return EOF (-1). And it is called very fast. If you check in this function, if...

Disable peripherals in debug mode on STM32F4xx 0

Disable peripherals in debug mode on STM32F4xx

Have you ever used watchdog in your application? Have you ever debug your application when watchdog was enabled and you hit stop? Watchdog did not stop in this case and when you pressed “continue” in your debugger, your program starts over because WDG has reset your system. One choice is that you remove line where you initialize IWDG, but you then must recompile and redownload and all that stuff. Wasting useful time. To avoid this problem, STM32 devices have possibility...

How to properly enable/disable interrupts in ARM Cortex-M? 7

How to properly enable/disable interrupts in ARM Cortex-M?

Point of this post is not how to use NVIC (Nested Vectored Interrupt Controller) in Cortex-M processors but how to disable/enable interrupts properly for your system to avoid strange behaviours in your code. Let’s assume you have 2 functions, which do some important stuff and they have to make sure that noone interrupts these 2 functions

ARM Cortex-M SCB ICSR register structure. From 1

Get interrupt execution status on Cortex-M processors

You might come to a situation when you wanna know if current code is executing inside interrupt or not. This might be handy when you do a library and you have one function which you wanna call in interrupt handler for specific event or without interrupt handler, buf wanna execute something specific in function only if you are currently in interrupt. You can create 2 different functions of course, but what if you have one very big function, and for...

CPU load monitor for STM32F4xx 0

CPU load monitor for STM32F4xx

I’ve been searching for a simple CPU load monitor on STM32F4xx device. Today, I’ve managed to get one very, very primitive CPU load monitor for these devices. Check library here. STM32F4xx have built-in DWT (Data Watchpoint and Trace unit) which has several timers there. 2 of them are cycle counter and sleep counter. The first counts number of CPU cycles and the second counts number of cycles where CPU was sleeping. It would be very easy to get CPU load,...