Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

FreeRTOS tutorial on STM32

A High-density line of STM32 microcontrollers has quite many features that can be used in your programs. However, the more features you add to the source, the more complicated the program becomes, and it may become challenging to keep up with all things. Relying on the main loop and interrupts becomes a time-consuming task to manage. If you do not want to struggle while tuning things up manually, you can use one of the best free real-time operating systems (RTOS). It is handy when you need many separate functions to run in parallel without missing a task. RTOS scheduler takes care of giving each task a required period to perform. There are many great RTOS systems around. Many of them are free and open source. Follow the FreeRTOS tutorial to see how easy it is to run complex tasks. I love using FreeRTOS, which has a long successful history and is flexible to fit multiple hardware types. You can check out my demo FreeRTOS tutorial on Atmega128. I also encourage you to give it a try for other RTOS systems like ChibiOS, BeRTOS, and others. FreeRTOS is quite simple and easy to use. It has practically all of the features…

Continue reading

Connecting STM32 USART to standard I/O streams in GCC

In many situations, when working with STM32 microcontrollers, you will want to output text strings. There is no need to write specialized functions that output specially formatted strings as it is hard to keep up with various cases. It is convenient to use standard I/O streams and their library functions that allow sending formatted data streams. Arm GCC toolchain comes with the newlib C library from Redhat, so it isn’t specially designed for the embedded toolchain. To use stdio functions, we have to take care of several syscals so-called “stub functions.” These functions usually are provided by operating systems like you would write C programs in Windows or Linux. In our case, we aren’t using any OS, so to avoid error messages while compiling, we have to provide these function declarations where most of them are dummy implementations. It’s not something new pick one that you find on the internet. I noticed that it was written for STM32 Discovery. I named it newlib_stubs.c and placed it in the startup directory. Among system functions implementations like _write(), _fstat(), etc., there are also USARTs assigned to standard streams:

Continue reading