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 (UART/I2C/SPI/ADC)ADC, EXTI, I2C device setup) in a way that is safe for code generation.
- IOC
FileFile::components/sensor_board/firmware/firmware.ioc - Generated HAL Init
FilesFiles::components/sensor_board/firmware/Core/Src/ - Application
EntryEntry::src/sensor_board/main.c (MainTask, entry set to "As external" in FreeRTOS tab)
Current CubeMX Snapshot
Item | Value |
|---|---|
MCU |
|
CubeMX Version | 6.15.0 |
STM32Cube FW Package | STM32Cube FW_H7 |
|
|
|
|
Enabled CubeMX Components
- CORTEX_M7 (I-
Cache/Cache and D-Cache enabled, MPU configured) - DMA (DMA1 Stream 0)
- ETH (RMII mode)
LWIPFREERTOS (StaticCMSIS-RTOS V2, defaultTask plus mainTask)- I2C1 (fast mode, for the IMU on PB8/PB9)
- LWIP (static IP, DHCP
disabled)disabled, static ARP entries enabled) FREERTOSTIM3 (CMSIS-RTOSPWMv2,GenerationdefaultCH3,taskpumpgenerated)MOSFET gate)TIM1TIM7 (base timer)- USART1 (asynchronous)
- SYS/NVIC/RCC base platform configuration (HAL timebase on TIM6)
Clock and Core Setup
Clock Configuration (from IOC)
Parameter | Value |
|---|---|
|
|
SYSCLK |
|
APB1 |
|
|
|
|
|
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,0x30000000, size32KB,32shareable,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 |
|
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 |
|
USART3_TX / USART3_RX | PD8 |
|
| PD9 |
|
RTOS Tasks and Interrupts
BoardFreeRTOS IOTasks /(CMSIS MiscV2)
|
|
| Entry |
|---|---|---|---|
|
|
| StartDefaultTask |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
|
Timer,
FreeRTOS RTOS,heap: and Interrupts
TIM1 Base Timer
htim1.Init.PrescalerconfigTOTAL_HEAP_SIZE = 640065536 -(64 1;
htim1.Init.Period = 10000;With a 72 MHz timer clock, this gives an update period near 0.89 s.KB).
Interrupt Priorities (Keykey Entries)entries)
IRQ | Priority | Notes |
|---|---|---|
ETH_IRQn |
|
|
|
|
|
|
|
|
EXTI15_10_IRQn |
| 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
Base timer and RTOSFreeRTOS scaffolding with the external MainTaskBasicI2C1UART-capablebus for the IMU with pull-ups on PB8/PB9- TIM3 CH3 PWM output for the pump
- GPIO pins and
NUCLEOlabelsCOMforintegrationthepathHX711 load cells and the flow sensor
What Is Not Yet Fully Modeled in CubeMX (TO-TO DO ONCEonce sensors are retrieved and assembled)
DedicatedADCADCperipherals and channels for the analog sensors (pH,loadpressure/FSR);cell,PD14pressure)and PD15 must also be moved to ADC-capable pinsDedicatedEXTI4I2C/SPIrising-edgebusesinterrupt forIMUtheandflowpressure variantsExplicit sensor-specificsensor pinlabelsPA4and(untilalternate-enabled, flow always reads 0)- IMU device bring-up on I2C1 (the poll function
assignmentsis a placeholder)
Important: Currentthe analog sensor drivers includeare placeholderscompile forgated hardware(PH_SENSOR_USE_ADC, accessPRESSURE_USE_ADC) inso multiplethe modules.firmware links without hardware. When bringing up physical sensors, add the corresponding CubeMX peripherals first, then updateenable the sensorbuild driversflags toand usebind the generated handles.
Recommended Workflow
- Open
components/sensor_board/firmware/firmware.iocin STM32CubeMX. - Add the required
peripheralsperipheral for the target sensorlike(ADCthis:
GPSEXTI -> USARTx (baud/parity/stop bits to match module)
IMU -> I2Cxline, or SPIxI2C (+ optional DRDY INT GPIO)
pH -> ADCx channel (sampling time, resolution)
Load Cell -> ADCx channel(s) or external ADC interface
Pressure -> ADCx or I2Cx/SPIx (depends on sensor part)ConflictConflicts To Look Out forCheck Before Saving the .ioc fileFile
- No conflict with ETH RMII pins (PA1, PA2, PA7, PC1, PC4, PC5, PG11,
PG13,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)