Questions tagged [stm32]

The STM32 is a family of microcontrollers from ST Microelectronics, based on the Cortex M0, M0+, M3, M4, or M7 ARM core (depending on the product line).

The STM32 is a product line from ST Microelectronics using 32-bit Cortex-M microcontrollers and/or Cortex-A microprocessors. There are a variety of microcontrollers with different power consumption and performance characteristics. Some microcontrollers also offer DSP and floating point functionality.

In addition to the line of microcontrollers, ST also offers a number of different evaluation boards and development boards. These boards contain a microcontroller on a PCB with additional support electronics and various sample sensors. The STM32CubeIDE Integrated Development Environment supports software development for these products.

Two such product lines are the Discovery kits such as the STM32F0DISCOVERY and STM32F3DISCOVERY boards and the Nucleo product line of prototyping boards.

As of Q1/2023, the family consists of:

MPU

  • STM32MP1 - Cortex A7 & Cortex M4 big.LITTLE

Low Power

  • STM32L0 - Low-Power Cortex-M0+
  • STM32L1 - Low-Power Cortex-M3
  • STM32L4 / L4+ - Low-Power Cortex-M4
  • STM32L5 - Low-Power Cortex-M33
  • STM32U5 - Ultra Low-Power Cortex-M33

High Performance

  • STM32F2 - High-Performance Cortex-M3
  • STM32F4 - High-Performance Cortex-M4
  • STM32F7 - High-Performance Cortex-M7
  • STM32H5 - High-Performance Cortex-M33 (up to 1 GHz)
  • STM32H7 - High-Performance Cortex-M7 (up to 550 MHz)

Main Stream

  • STM32F0 - Mainstream Cortex-M0
  • STM32F1 - Mainstream Cortex-M3
  • STM32F3 - Mainstream Cortex-M4
  • STM32G0 - Mainstream Cortex-M0+ (upgrading STM32F0)
  • STM32G4 - Mainstream Cortex-M4 (upgrading STM32F3)

Wireless MCUs

  • STM32WB - M4/M0 with BLE, Zigbee
  • STM32WL - M4/M0 with LoRaWAN
5104 questions
7
votes
1 answer

Does fwrite flush the buffer on '\n'?

I have my own implementation of _open(), _close(), _write(), _read(). My code: FILE *f = fopen("0:test", "wb"); // calls _open() fwrite("hello ", 6, 1, f); fwrite("world\r\n\0", 8, 1, f); // calls _write(3, "hello world\r\n", 13) fflush(f); …
Cosinus
  • 534
  • 4
  • 10
7
votes
3 answers

reading a 64 bit volatile variable on cortex-m3

I have a 64 bit integer variable on a 32 bit Cortex-M3 ARM controller (STM32L1), which can be modified asynchronously by an interrupt handler. volatile uint64_t v; void some_interrupt_handler() { v = v + something; } Obviously, I need a way to…
7
votes
2 answers

Global variables between C and C++

I'm developing a mixed C/C++ program for an ARM STM32F4, but I have problems in accessing global variables defined in the C part. Here is a simple test code to reproduce the problem. test.h: #ifndef TEST_H_ #define TEST_H_ #ifdef __cplusplus extern…
apalazzi
  • 73
  • 6
7
votes
2 answers

Does the Cortex-M3 STM32F103 core stall during a flash page erase because the FPEC is busy and can't fetch any more instructions from flash?

On the STM32F103, the erasing of a flash page takes 20ms during which the core stalls for me. It's not clear from the ST PM00042 Flash programming manual whether the core would always stall when erasing a flash page or whether it just stalls because…
Captain NedD
  • 337
  • 1
  • 5
  • 11
7
votes
1 answer

STM32 I-CODE and D-CODE buses

STM32 documentation says that the I-CODE and D-CODE buses are connected to the internal flash memory. The I-CODE bus is used to fetch instructions and the D-CODE bus is used for data access in the code memory region (literal load). The question is…
lvds
  • 127
  • 2
  • 7
7
votes
4 answers

How do I execute a function from RAM on a Cortex-M3 (STM32)?

I'm trying to execute a function from RAM on a Cortex-M3 processor (STM32). The function erases the and rewrites the internal flash, so i definitely needs to be in RAM but how do I do that? What I have tried is this: Copy the function to a byte…
c0m4
  • 4,343
  • 10
  • 35
  • 40
7
votes
2 answers

Can't write to flash memory after erase

So I can't write to internal flash memory directly after erasing it. If there's no erase operation before write operation, then I can. Any ideas as to why? Programming function returns 'successful write' value, but when looking at memory, no data is…
andrey
  • 1,515
  • 5
  • 23
  • 39
7
votes
4 answers

Struct packing and alignment with mingw

I am emulating code from an embedded system (stm32, Keil µVision 5, MDK-ARM) on a PC (mingw32, 32bit arch). The alignment of the ARM compiler does not match my desktop mingw build: // ARM Code (ARM compiler uses __packed) typedef __packed struct…
clambake
  • 772
  • 4
  • 15
7
votes
1 answer

How to delay one clock cycle in STM32?

The question is as simple as the topic. How to delay exact one clock cycle in STM32? If the controller runs at 168MHz, is one clock cycle equal to 1/168MHz, which is 5.95ns?
richieqianle
  • 602
  • 2
  • 7
  • 20
7
votes
1 answer

Error -3 opening ST-Link/V2 device

I'm trying to compile and upload an STM32F4 Discovery project through Eclipse under Linux Mint 16. The project compiles correctly, but during the upload I get the error: WARN src/stlink-usb.c: Error -3 opening ST-Link/V2 device 003:007 I'm using…
ascallonisi
  • 871
  • 1
  • 11
  • 20
7
votes
2 answers

How to display time on stm32-discovery

I've been experimenting with the STM32-DISCOVERY a lot lately, but I'm not sure how to get started with an application for this board. I want to show the time of the RTC on the stm32's display. How do I get started with this? I have already…
Niels Robben
  • 1,637
  • 4
  • 17
  • 24
7
votes
1 answer

Stm32L151RCxxx USART Hang issue, Interrupt Based TX/RX simultaneously

I am running USART3, on 921600 BaudRate, using RTS CTS, I am always facing system hang when I try to do RX and TX simultaneously. I have pasted the main and IRQ code. IRQ is designed to Transmit a char 'A' while dropping all received data. Hangs…
Ishmeet
  • 1,540
  • 4
  • 17
  • 34
7
votes
5 answers

How generate REAL random number using STM32 MCU?

I'm working on a project with STM32F103E arm cortex-m3 MCU in keil microvision IDE. I need to generate random numbers for some purposes, but I don't want to use pseudo-random numbers which standard c++ libraries are generating, so I need a way to…
Ehsan Khodarahmi
  • 4,772
  • 10
  • 60
  • 87
6
votes
1 answer

Why does D2 RAM work correctly even when clock is disabled?

TL;DR: documentation states I have to enable a specific memory region in the microcontroller before I can use it. However, I can use it before enabling it, or even after disabling it. How is this possible? I'm currently developing an application…
wovano
  • 4,543
  • 5
  • 22
  • 49
6
votes
1 answer

STM32CubeMx: How to add your own "USER CODE BEGIN / END" section?

I have a project where I need to add a few lines to one of the generated C files. However, the place where I want to add the change does not have a "USER CODE BEGIN / END" section. So whenever, I regenerate code, the changes are overwritten. I tried…
Dojo
  • 5,374
  • 4
  • 49
  • 79