🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 7 Min Lesezeit
0

PlatformIO: A Better Way to Code for STM32 Microcontrollers

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




1. STM32 Microcontrollers



The STM32 series is a popular, affordable, and high-performance family of microcontrollers. They enjoy extensive support from various development software suites tailored for microcontrollers. STM32 microcontrollers provide numerous peripherals that can be connected to a wide range of electronic components, such as sensors, displays, and electric motors.



The performance range of STM32 microcontrollers is quite broad. The most basic models, like the STM32F0 and STM32F1 series, start with a clock frequency of 24 MHz and are available in packages with as few as 16 pins. In contrast, the STM32H7 series can operate at speeds of up to 400 MHz and comes in packages with 240 pins. Additionally, the STM32L series is specifically designed for low-power applications that run on small batteries.



To develop code, program the microcontroller, and debug applications, development software is necessary. This software suite should include a compiler, a debugger, and an in-circuit serial programmer (ICSP).





After a few minutes, the installation is complete, and we now have PlatformIO installed in the VSCode IDE. PlatformIO offers some unique features, the most notable being its declarative development environment. With PlatformIO, we only need to specify the components we will use in our project, including the chip type, the framework, the version of that framework, and any additional libraries with their version constraints. We'll explore the meaning of these components and how to configure a project shortly. Additionally, PlatformIO provides all the essential tools needed for developing embedded projects, such as debugging, unit testing, static code analysis, and firmware memory inspection.






3. ST-LINK



The ST-LINK debugger is a versatile in-circuit debugger and programmer designed for STM32 microcontrollers, developed by STMicroelectronics. It provides a seamless interface for debugging and programming STM32 devices through the SWD (Serial Wire Debug) or JTAG interfaces. The ST-LINK is widely used in development environments due to its compatibility with popular IDEs such as STM32CubeIDE and Keil MDK. It offers features like real-time debugging, breakpoints, and flash programming. Its compact design and ease of use make it an essential tool for developers working with STM32 microcontrollers, facilitating efficient development and troubleshooting of embedded applications.






3.1. Prepare ST-LINK on Linux



In order for OpenOCD to properly access and communicate with USB devices on Linux, it’s essential to add a custom udev rule. By default, OpenOCD may not have the necessary permissions to interact with USB devices like ST-Link. The udev rule grants the appropriate permissions to these devices, ensuring that OpenOCD can successfully connect to them. To do this, you need to create a udev rule file in the /etc/udev/rules.d/ directory, specifying the correct vendor and product IDs of the connected debugger.



By executing the command below, we can find information about our device, including the vendor ID and product ID.




CODE
lsusb











4.2. Click on the New Project button on the right of the same screen.








4.4. Directory Structure



When the project is created, we have the following directory structure.





Now in the clock configuration choose 72 MHz.








4.5.3. USART Configuration



For this project we used USART1 to sending message from microcontroller. You should Configuring PA9 and PA10 for RX and TX.








4.5.4. Code Generating



After configuring the microcontroller, you can generate the necessary initialization code. This code typically involves setting up the clock configuration registers to select the HSE as the PLL source and configuring the PLL multiplier.





For the PlatformIO project, we only need the Inc and Src folders in the Core directory. Copy them from the current location to the corresponding directory in the PlatformIO project structure.






4.6. Coding



The generated code includes multiple comments that guide us on how to modify and add our own code. To achieve our goal, we need to locate the main function, which signifies the start of the program. Inside the main function, we should find the while loop and incorporate the LED toggling logic within it, along with a delay to blink the LED connected to pin B7. Additionally, before entering the while loop, we should send the message "Hello dev.to" at the beginning of the program.




CODE
int main(void)
{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Transmit(&huart1, (uint8_t *)"Hello dev.to", 13, 1000);
/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);
HAL_Delay(250);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}







  • HAL_GPIO_TogglePin: This function toggles the state of the LED pin (turning the LED on and off).


  • HAL_Delay: This introduces a 500ms delay between toggles, giving the LED a blinking effect.


  • HAL_UART_Transmit: This transmits the “Hello dev.to” string over USART1 to a connected serial terminal. The huart1 variable is automatically generated in STM32CubeMX and refers to the USART1 handler.







4.7. Build and Run



To build the project, you can use the build button, and to run it, you can click on the Upload button in the PlatformIO extension. Alternatively, you can use the following commands in the PlatformIO terminal emulator inside VSCode.




CODE
pio run --environment blackpill_f103c8
pio run --target upload --environment blackpill_f103c8










    • Oner, V. O. (2021). Developing IoT Projects with ESP32: Automate your home or business with inexpensive Wi-Fi devices. Packt Publishing Ltd.



    Developing IoT Projects with ESP32

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
  • Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    Hackers Just Poisoned the Rust Supply Chain | Threat Wire
    1 Quelle
    Hackers Found a Way Into Humanoid Robots | Threat Wire
    1 Quelle
    Bits und so #1021 (Passwort für Laufwerk)
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten PlatformIO: A Better Way to Code for STM32 Microcontrollers

    Thematisch verwandte Begriffe: PlatformIO, Better, Code, STM32 · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...