STM32 ONE PULSE MODE.

STM32 ONE PULSE MODE.
STM32

In one of my projects I used the following mechanism to control a buzzer: I turned it on manually, started a timer and turned it off in the interrupt triggered by the timer overflow. Over time the number of interrupts in the project grew, and other interrupts often prevented the one that turned off the buzzer from firing. As a result, the buzzer always produced a beep of varying length...

STM32 I2S.

STM32 I2S.
STM32

The I2S protocol, not to be confused with I2C, is designed for transmitting an audio stream. In my device this protocol is used to transfer the audio stream between a codec and the MCU. I'd like to note right away that STM32 has no separate I2S module as such; the one it has is implemented on the basis of the SPI module, and they share the same DR[0:15] register...

STM32 I2C.

STM32 I2C.
STM32

Lately I keep coming across negative reviews of the I2C bus on STM32, saying that working with it is like performing a ritual dance and so on. Over the past month I managed to get two I2C chips working without any dancing, just careful reading of the datasheet...

STM32 FLASH.

STM32 FLASH.
STM32

I think regular visitors to the site have noticed that I prefer to do everything with registers, but sometimes I still use SPL. For example, the article about a custom bootloader used library functions to work with flash memory. Once again connecting this library, I decided that it takes up too much space and decided to implement the necessary functions myself. To work with flash memory...

STM32 RTC, Calendar.

STM32 RTC, Calendar.
STM32

Let's start with the fact that RTC is an abbreviation that stands for Real-time clock. In the old days, when I used AVR MCUs, I used a separate chip as the RTC and communicated with it over a specific protocol. On STM32, however, the RTC is a module implemented inside the MCU. On STM32 the RTC has the following...

STM32: Problems Connecting a Display via LTDC.

STM32: Problems Connecting a Display via LTDC.
STM32

In one of my previous articles I described how to connect a display to an STM32 microcontroller using the LTDC interface. The article ended with a video showing an image on the display built into the DISCOVERY board. Naturally, my next wish was to run something bigger and connect it myself, so that I'd have a complete picture in my head. I ordered a 7-inch display from China...

STM32 DMA MEM2MEM.

STM32 DMA MEM2MEM.
STM32

In one of my previous articles I already described what DMA is and gave an example of it working together with an ADC. In that example, the ADC conversion results were written to a buffer without involving the core. This time I needed to move a buffer from one memory area to another, and I knew for sure that this can be done with DMA using MEM2MEM mode...

STM32 Frequency Measurement.

STM32 Frequency Measurement.
STM32

In one of my previous articles I talked about the STM32 capture mode and gave an example of how to use it to measure a signal's period. But this method can't ACCURATELY measure the period of a high-frequency signal (it will become clear below which signal counts as high-frequency). Suppose the frequency of the signal under test is 1MHz and our timer counts 72 million per second. Let's convert the frequency to a period...

STM32 Fast Fourier Transform.

STM32 Fast Fourier Transform.
STM32

For a long time I wanted to add a Fourier transform to the oscilloscope I described here, but for some reason I never got around to it. Quite recently, a month ago, I decided to increase the scope's sampling rate by replacing the stm32F103VE with a 1M sampling rate with an stm32F303VC with a 5M sampling rate. After replacing the chip and changing the program, I finally decided to figure out the fast Fourier transform (FFT)...

STM32 BSRR VS ODR.

STM32

I think those reading this article know that you can write a one to bit zero of port A in two ways: GPIOA->ODR |= GPIO_ODR_ODR0; or GPIOA->BSRR = GPIO_BSRR_BS0; And everyone writes that the second way is more correct, because setting the bit is then atomic. That's hard to argue with. Now let's imagine a situation: we have an eight-bit bus over which data is transmitted, connected...

Measuring Temperature with a Thermocouple, Using the MAX6675 with STM32 as an Example.

Measuring Temperature with a Thermocouple, Using the MAX6675 with STM32 as an Example.
STM32

Recently I needed a reflow soldering oven. For those who don't know what it is, I'll briefly describe how it works and what it's for. I have a dozen boards that need to be assembled, and the components on them are mostly SMD. Right now the boards are assembled as follows: first I apply solder paste to the pads with a syringe, then I place the components...

STM32 Clock Configuration.

STM32 Clock Configuration.
STM32

At first, to simplify writing programs for STM32, I didn't go into the details of configuring the clock system; instead I selected the system bus frequency in the system_stm32f10x.c file by simply uncommenting the desired line. But when it came to configuring the clock frequency of individual blocks (for example the ADC), I used CUBE. The whole clock system is in front of your eyes, which is very convenient and...

Connecting a Resistive Touch Panel with an XPT2046 Driver to STM32 and Calibrating It Using Four Points.

Connecting a Resistive Touch Panel with an XPT2046 Driver to STM32 and Calibrating It Using Four Points.
Дисплеи

There are already several articles about resistive touch panels on this site: here you can read how they work, and here how to connect one to an AVR and calibrate it. So below I'll only talk about the subtleties of working with such a panel. As you know, data exchange with the XPT2046 happens over SPI, so you just need to find a free one and connect to it. Usually, to see which pins are assigned to which SPI...

Connecting a TFT Display to STM32 via FSMC, Using the SSD1963 as an Example.

Connecting a TFT Display to STM32 via FSMC, Using the SSD1963 as an Example.
Дисплеи

Here's how it happened: one of the site's visitors sent me, as a gift, a 5-inch TFT display controlled by the SSD1963 driver. About ten days later the parcel arrived, but the box it was packed in was dented and the display itself was broken. I wrote to the sender about it, and he immediately ordered the same display on eBay in my name, for which I thank him. No more than two weeks had passed since...

Creating a Project in Keil uVision.

Creating a Project in Keil uVision.
STM32

One of the questions that comes up when switching to STM32 is: "Which development environment should I choose?" The most popular ones are probably Coocox, IAR and Keil uVision; I use the last one. Its main advantage over the others is a powerful simulator with peripheral support and many virtual instruments. All these goodies "make life easier" for an experienced developer and help a beginner figure out the rich...

STM32 Input Capture Mode.

STM32 Input Capture Mode.
STM32

Capture mode is a special timer mode that works like this: when the logic level on a certain microcontroller pin changes, the value of the counter register is written to another register, called the capture register. What is it for? This mode lets you measure the pulse width or period of a signal. The STM32 capture mode has some features:...

STM32: Triggering the ADC from a Timer.

STM32: Triggering the ADC from a Timer.
STM32

The other day I needed to start an ADC conversion once per second, and it immediately became clear that this can't be done with the SMPR[2:1] bits, which set the number of cycles between ADC samples, so I had to find another way. The maximum number of cycles between samples that can be set with these bits is 239.5. If you add the conversion time of 12.5...

STM32 Debugging over SWD.

STM32 Debugging over SWD.
STM32

STM32 has a very convenient interface for debugging and flashing the MCU: Serial Wire Debug, SWD for short. Its convenience is that debugging requires connecting only two data pins plus two power pins. The wiring diagram looks like this. Once the pins are connected, you need to enable SWD debugging in the development environment; in KEIL this is done as follows...

STM32 SPI3 Not Working.

STM32 SPI3 Not Working.
STM32

Usually, before building a device, I implement the basic functionality on a breadboard, and this time was no exception. After the basic functionality was implemented, I started routing the board, and along the way it turned out that it was much easier to route the board using SPI3 rather than SPI2, which was used in the project. Why make things hard for myself, I thought at the time, and routed the board using SPI3...

STM32 Low-Power Modes.

STM32 Low-Power Modes.
STM32

First I'd like to say a couple of words about the microcontroller's supply voltages: STM32 needs 2 to 3.6V for normal operation, and the built-in regulator provides 1.8 volts to power the core. Below is a schematic of the controller's overall power supply. As you can see, the power supply is divided into domains, each responsible for powering certain peripherals/parts of the MCU. You can reduce consumption...