Introducing to STM32 ADC programming. Part1

STM32 ADC is a pretty complex peripheral. It is designed to be flexible enough to accomplish complex tasks. We will dedicate a few posts where we will try to cover the main features and give working examples of code. The block schematic may look scary the first time, but it can be split into several pieces that are responsible for different functions if you look closer. Will will go through them step by step to make it look brighter.

Continue reading

Programming STM32 USART using GCC tools. Part 1

When we need some feedback from the microcontroller, usually we use USART. It allows to output messages and debug information to the terminal screen. Also, data can be sent to MCU same way. For this purpose, STM32 microcontrollers have more than one USART interface allowing to have multiple streams of data output and input. USART interface is designed to be very versatile, allowing to have lots of modes including LIN, IrDA, Smart card emulation, DMA based transmissions. But for now, let’s focus on standard USART communications we could send and receive messages from the terminal window.

Continue reading

STM32 interrupts and programming with GCC

Probably one of the key features of any microcontroller is the interrupt system. ARM Cortex-M3 microcontrollers may have up to 256 interrupted sources. The first 15 interrupt sources are called system exceptions. These exceptions arise within Cortex core like reset, NMI, hard fault and error, debug, and SystTick timer interrupt. In the exception table, they start from address 0x00000004 and are numbered from 1 to 15. There is no 0 number exception (FYI – the very top of exception table address is used to store the starting point of stack pointer): Each exception vector holds the four-byte address of the service routine that is called when an exception occurs. Exception table usually is located in startup code like this:

Continue reading