Push-pull VS open-drain.

Push-pull  VS open-drain.
STM32

At the end of the previous article I promised to explain how a push-pull (PP) output differs from an open-drain (OD) output. To understand this, let's look at how a push-pull output is built. Essentially, it consists of two switches: one pulls the pin up to the supply, the other pulls it down to ground. And now open-drain...

STM32F3 and STM32F4 GPIO.

STM32F3 and STM32F4 GPIO.
STM32

An article about configuring STM32 pins was published on this site earlier; it was dedicated to the F1 series microcontrollers, although the article didn't say so explicitly. This article covers the F3 and F4 series microcontrollers. Before configuring any MCU pin, you must enable the clock for the corresponding port!!! Each MCU pin can be configured in one of the states. In...

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...

STM32 Delay Function.

STM32 Delay Function.
STM32

The first thing I noticed after switching from AVR to STM32 was the absence of the familiar delay functions delay_us() and delay_ms(). Well, if they're missing, they're missing, I thought at the time, and whenever I needed a delay, I did it like this...

SPI STM32.

SPI STM32.
STM32

We won't go over how the protocol works, since it was covered here; let's go straight to the capabilities of the STM32 SPI module: full-duplex synchronous transfer using 3 lines; simplex synchronous transfer using two lines, with the option of a bidirectional data line; 8- or 16-bit frame format; operation in Master or Slave mode; in Master mode 8...

STM32 Interrupts.

STM32 Interrupts.
STM32

On STM32, interrupts are managed by the NVIC (Nested Vectored Interrupt Controller). Let's look at its capabilities: handling up to 81 interrupts, depending on the MCU model; a programmable priority level from 0 to 15 for each interrupt, with level 0 being the highest priority; dynamic priority changes; dividing interrupts into groups, and within groups into...

STM32 Code Execution Time.

STM32 Code Execution Time.
STM32

It all started when I needed to at least roughly estimate the execution time of a piece of code. It turned out that microcontrollers with a Cortex-M3 core have a special module for this called the Data Watchpoint and Trace Unit, DWT for short. To configure DWT to measure code execution time, we need to set 2 bits. The TRCENA bit in the DEMCR register, setting...

STM32 PWM.

STM32 PWM.
STM32

PWM on STM32 is generated using timers; the documentation says a lot about them, but PWM turned out to be quite easy to configure. We'll generate PWM using channel 4 of timer 1. First, we need to find which pin is responsible for channel 4 of timer 1; to do this, open the Technical DataSheet for your MCU (mine is the STM32F103VET6) and find which pin has...