Skip to content

mbahScript/PI-STM32-UART-INTERFACE

Repository files navigation

STM32F767ZI to Raspberry Pi 5 UART Communication

STM32 Language Raspberry Pi 5 UART Embedded Systems HAL Microcontroller Serial Communication Status

1. Project Overview

This project demonstrates UART communication between an STM32F767ZI Nucleo-144 board and a Raspberry Pi 5.

  • Problem being solved: Establishing a reliable UART link between STM32 and Pi for embedded system data exchange.
  • Purpose: Allows the STM32 to send periodic status messages to the Raspberry Pi, forming the foundation for sensor or control data transfer.
  • Demonstration: Counts incrementally transmitted from STM32 and displayed on the Raspberry Pi terminal.

2. System Architecture

  • High-level description: STM32 runs a loop sending UART messages, Raspberry Pi receives them via GPIO UART pins.
  • Data flow: STM32 → UART → Pi → Terminal Display
  • Control flow: Simple polling loop on STM32, no interrupts used.

3. Hardware Design

  • STM32F767ZI Nucleo-144: Chosen for high-performance Cortex-M7, multiple UARTs.
  • Raspberry Pi 5: Receives UART data, acts as a display or processing unit.
  • Jumper wires: For TX/RX and GND connections.

Power considerations: Both boards are powered by their standard USB sources.

System Diagram

4. Firmware / Software Design

  • Firmware structure: HAL-based initialization, main loop sends messages.
  • Tasks: Main polling loop, message formatting with counter.
  • Code snippet:
int counter = 0;
char msg[50];
while(1) {
    sprintf(msg, "Hello STM32! Count=%d\r\n", counter++);
    HAL_UART_Transmit(&huart3, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
    HAL_Delay(1000);
}
  • Timing: 1-second interval between messages.

5. Communication & Interfaces

  • Protocol: UART (USART3)
  • Reason: Simple, low-latency point-to-point communication.

6. Implementation Highlights

  • Correct GPIO alternate function configuration for PB10/PB11.
  • Use of HAL_UART_Transmit in blocking mode for simplicity.
  • Counter-based message to verify continuous communication.
  • Minimal code footprint for embedded teaching or prototyping.

7. Challenges & Debugging

  • Initial blank screen on Pi due to serial-getty and default UART mapping.
  • Resolved by disabling serial console, enabling hardware UART, and verifying pinctrl mapping.
  • Python loopback test used to verify Pi UART before connecting STM32.

8. Results & Demonstration

  • STM32 transmits "Hello STM32! Count=N" every second.
  • Raspberry Pi terminal (screen /dev/serial0 115200) receives messages in real-time.
  • Validates end-to-end UART communication.

Demonstration

9. Security, Reliability, or Safety Notes

  • Pull-up resistors configured on PB10/PB11 for stable logic levels.
  • UART blocking transmit ensures no message loss in this simple demo.
  • Grounding required between STM32 and Pi.

10. Future Improvements

  • Implement STM32 RX handling to allow bidirectional communication.
  • Add message framing and checksums for robust data transfer.
  • Integrate into a larger sensor or control system.
  • Explore DMA-based UART for non-blocking transmissions.

11. Repository Structure

/core        -> Core STM32 firmware code
/driver      -> Peripheral drivers
/images      -> Diagrams, pinout, screenshots
/README.md   -> Project documentation
/LICENSE     -> License file (stay intact)

Platform-Specific Notes (STM32)

  • MCU: STM32F767ZI Cortex-M7
  • HAL Drivers: Used for UART, GPIO, and system clock
  • Debugging tools: ST-Link, CubeIDE
  • UART AF: PB10 (TX), PB11 (RX), AF7
  • No RTOS: Bare-metal polling loop for simplicity
  • Clock: HSI + PLL configuration for system stability

About

STM32F767ZI to Raspberry Pi 5 UART Communication – Demonstrates reliable UART data exchange between an STM32 Nucleo-144 board and a Raspberry Pi 5.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages