STM32CubeMX Sensor Configuration
This page documents the current STM32CubeMX configuration for the Sensor Board firmware and explains how to extend it for the remaining sensor interfaces (ADC, EXTI, I2C device setup) in a way that is safe for code generation.
- IOC File: components/sensor_board/firmware/firmware.ioc
- Generated HAL Init Files: components/sensor_board/firmware/Core/Src/
- Application Entry: src/sensor_board/main.c (MainTask, entry set to "As external" in FreeRTOS tab)
Current CubeMX Snapshot
Item | Value |
|---|---|
MCU | STM32H753ZITx (NUCLEO-H753ZI) |
CubeMX Version | 6.15.0 |
STM32Cube FW Package | STM32Cube FW_H7 V1.12.1 |
Build system | PlatformIO (env:sensor_board), stm32cube framework |
Enabled CubeMX Components
- CORTEX_M7 (I-Cache and D-Cache enabled, MPU configured)
- DMA (DMA1 Stream 0)
- ETH (RMII mode)
- FREERTOS (CMSIS-RTOS V2, defaultTask plus mainTask)
- I2C1 (fast mode, for the IMU on PB8/PB9)
- LWIP (static IP, DHCP disabled, static ARP entries enabled)
- TIM3 (PWM Generation CH3, pump MOSFET gate)
- TIM7 (base timer)
- USART1 (asynchronous)
- SYS/NVIC/RCC base platform configuration (HAL timebase on TIM6)
Clock and Core Setup
Clock Configuration (from IOC)
Parameter | Value |
|---|---|
HSE crystal value | 8 MHz |
SYSCLK | 64 MHz |
APB1 | 64 MHz |
Note: the STM32H753 is capable of 480 MHz, but the current IOC runs the core at 64 MHz. Raising the clock requires PLL configuration in the Clock Configuration tab and re-validation of the Ethernet and FreeRTOS timing.
Cortex-M7 / MPU
- Instruction cache: enabled
- Data cache: enabled
- MPU region at 0x30000000, size 32 KB, full access, TEX level 1 (non-cacheable region for the Ethernet DMA descriptors and LwIP heap)
- LwIP RAM heap pointer: 0x30004900, MEM_SIZE 16 KB
Pinout and Peripheral Mapping
Ethernet (RMII)
Signal | Pin |
|---|---|
ETH_REF_CLK | PA1 |
ETH_MDIO | PA2 |
ETH_CRS_DV | PA7 |
ETH_MDC | PC1 |
ETH_RXD0 | PC4 |
ETH_RXD1 | PC5 |
ETH_TX_EN | PG11 |
ETH_TXD0 | PB12 |
ETH_TXD1 | PB13 |
Sensor and Actuator Pins (labeled in IOC)
Label | Pin | Mode | Used by |
|---|---|---|---|
FLOW_SENSOR | PA4 | GPIO Input (EXTI4 not yet enabled) | Flow sensor pulse counting |
WEIGHT_INPUT_1 | PA5 | GPIO Input | HX711 unit 0 DOUT |
WEIGHT_INPUT_2 | PA6 | GPIO Input | HX711 unit 1 DOUT |
WEIGHT_CLOCK_1 | PC7 | GPIO Output | HX711 unit 0 SCK |
WEIGHT_CLOCK_2 | PB5 | GPIO Output | HX711 unit 1 SCK |
IMU_I2C_Clock | PB8 | I2C1_SCL (pull-up) | IMU |
IMU_I2C_Data | PB9 | I2C1_SDA (pull-up) | IMU |
WATER_PUMP_PWM | PC8 | TIM3_CH3 (PWM) | Pump MOSFET gate |
PH_ANALOG_DATA | PD14 | GPIO_Analog | pH sensor (see warning below) |
FORCE_ANALOG_DATA_1 | PD15 | GPIO_Analog | Pressure/FSR sensor 0 (see warning below) |
FORCE_ANALOG_DATA_2 | PF3 | GPIO_Analog | Pressure/FSR sensor 1 (PF3 = ADC3_INP5) |
STEPPER_MOTOR_1..4 | PD7, PD6, PD5, PD4 | GPIO Output | Reserved for the sampling stepper |
Warning: on the STM32H753, PD14 and PD15 have NO ADC function. The pH analog input and FORCE_ANALOG_DATA_1 must be moved to ADC-capable pins (for example PA0, PC0, or PF3-class pins) before the analog drivers can be enabled. PF3 maps to ADC3_INP5 and can be used as is.
Serial / COM
Signal | Pin | Note |
|---|---|---|
USART1_TX / USART1_RX | PA9 / PA10 | Spare asynchronous UART |
USART3_TX / USART3_RX | PD8 / PD9 | NUCLEO ST-Link VCP path, used by the logging system (hcom_uart[COM1]) |
RTOS Tasks and Interrupts
FreeRTOS Tasks (CMSIS V2)
Task | Priority | Stack (words) | Entry |
|---|---|---|---|
defaultTask | 24 | 128 | StartDefaultTask (generated) |
mainTask | 39 | 2048 | MainTask, "As external" (defined in src/sensor_board/main.c) |
FreeRTOS heap: configTOTAL_HEAP_SIZE = 65536 (64 KB).
Interrupt Priorities (key entries)
IRQ | Priority | Notes |
|---|---|---|
ETH_IRQn | 5 | Ethernet / LwIP path |
DMA1_Stream0_IRQn | 5 | DMA |
USART1_IRQn | 5 | Spare UART |
EXTI15_10_IRQn | 5 | External interrupt group (user button) |
TIM6_DAC_IRQn | 15 | HAL tick timebase (TIM6) |
SysTick / PendSV | 15 | FreeRTOS kernel |
Sensor Interface Status
What Is Already Configured in CubeMX
- Networking stack (LwIP) and RMII pinout
- FreeRTOS scaffolding with the external MainTask
- I2C1 bus for the IMU with pull-ups on PB8/PB9
- TIM3 CH3 PWM output for the pump
- GPIO pins and labels for the HX711 load cells and the flow sensor
What Is Not Yet Modeled in CubeMX (TO DO once sensors are retrieved and assembled)
- ADC peripherals and channels for the analog sensors (pH, pressure/FSR); PD14 and PD15 must also be moved to ADC-capable pins
- EXTI4 rising-edge interrupt for the flow sensor pin PA4 (until enabled, flow always reads 0)
- IMU device bring-up on I2C1 (the poll function is a placeholder)
Important: the analog sensor drivers are compile gated (PH_SENSOR_USE_ADC, PRESSURE_USE_ADC) so the firmware links without hardware. When bringing up physical sensors, add the corresponding CubeMX peripherals first, then enable the build flags and bind the generated handles.
Recommended Workflow
- Open components/sensor_board/firmware/firmware.ioc in STM32CubeMX.
- Add the required peripheral for the target sensor (ADC channel, EXTI line, or I2C settings).
- Assign and lock pins in the Pinout view; avoid overlap with RMII and COM pins.
- Configure clocks for new peripherals in Clock Configuration.
- Set NVIC priorities for new ISR sources so Ethernet and RTOS timing remain stable.
- Generate code with Keep User Code enabled.
- Rebuild using PlatformIO and validate startup and sensor polling.
Conflicts To Check Before Saving the .ioc File
- No conflict with ETH RMII pins (PA1, PA2, PA7, PC1, PC4, PC5, PG11, PB12, PB13)
- No conflict with the debug/COM path (PA9/PA10 and PD8/PD9)
- No conflict with oscillator pins (PH0, PH1, PC14, PC15)
- No conflict with the existing sensor labels (PA4, PA5, PA6, PB5, PB8, PB9, PC7, PC8, PD4..PD7, PD14, PD15, PF3)
No comments to display
No comments to display