Loading color scheme

How to Reset STM32 MCU Programatically?

stm32 nucleo

While the STM32 controller is reset at the power cycle, sometimes it is needed to reset the controller programmatically. This is needed in the process of severe system failure, misconfiguration of internal hardware, or during the firmware update process. So, how can we reset the STM32 Microcontroller programmatically?

The answer to the question on How to Reset the STM32 Microcontroller is the following. The correct function for this is NVIC_SystemReset(). Call this function from any place of code and it will never return, but reset the controller. The alternate function is HAL_NVIC_SystemReset(), just an alias for the above.

Read more
[Code Sample] Retrieve C++ Application Version from VS_VERSION Resource

Version Resource

Sometimes you may need to retrieve the application version from its own resources. While sounding trivial, this task is not so easy to solve. While you can easily access string resources or dialog resources using the dedicated WinAPI functions, the version resource retrieval is not so easy. That's because the corresponding function VerQueryValue is intended for retrieving versions from another loaded module, not from own executable. So, how would you retrieve the application version from your own executable then?

Read more
Access single file from different threads or processes and maintain consistensy without using extra locks

Sometimes you want to access a single file from different processes or threads and maintain its consistency. The example may be a common database or just a counter. When the file is opened in read-only mode, the question is trivial. But what if you want to write from different threads? Here is the code sample. The idea is to use File.Open constructor with the FileShare.None option. This option allows only one thread to access the file (either for reading or writing) and deny all other threads. The other threads should catch IOException and try to access the file subsequently with a random delay.

Read more
Get all interesting articles to your inbox
Please wait