Skip to main content

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

STM32H753ZIT6STM32H753ZITx (NUCLEO-H753ZI)

CubeMX Version

6.15.0

STM32Cube FW Package

STM32Cube FW_H7 v1.V1.12.1

ToolchainBuild system

MakefilePlatformIO +(env:sensor_board), GCC

Post-generationstm32cube Script

../../../scripts/post_code_generation.bashframework

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-RTOSPWM v2,Generation defaultCH3, taskpump generated)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

ClockHSE Sourcecrystal value

HSE 8 MHz -> PLL

SYSCLK

7264 MHz

APB1

36 MHz (DIV2)

APB2/APB3/APB4

72 MHz

TIM1 Clock

7264 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,0x30000000, size 32KB,32 shareable,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

PG13PB12

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

Configured in/ generated

MX_GPIO_Init()

USART1_RX

PA10

ConfiguredSpare inasynchronous generated

MX_GPIO_Init()UART

USART3_TX / USART3_RX

PD8

Used by/ NUCLEO COM path (

MX_USART3_Init

 in app init)

USART3_RX

PD9

UsedNUCLEO ST-Link VCP path, used by NUCLEOthe COMlogging pathsystem (

MX_USART3_Init

 in app init)hcom_uart[COM1])

RTOS Tasks and Interrupts

BoardFreeRTOS IOTasks /(CMSIS MiscV2)

PinTask

ModePriority

TypicalStack Use(words)

Entry

PC13defaultTask

GPIO Input24

User128

StartDefaultTask button(generated)

PB0mainTask

GPIO Output39

Board output line

PB72048

GPIOMainTask, Output

Board"As outputexternal" line

PB14

GPIO(defined Output

Boardin output line

PH0 / PH1

HSE oscillator

System clock source

PC14 / PC15

LSE oscillator

Low-speed oscillatorsrc/sensor_board/main.c)

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

155

Ethernet/Ethernet / LwIP path

TIM1_UP_IRQnDMA1_Stream0_IRQn

125

TIM1 update interruptDMA

TIM2_IRQnUSART1_IRQn

75

HALSpare tick time baseUART

EXTI15_10_IRQn

65

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 MainTask
  • BasicI2C1 UART-capablebus for the IMU with pull-ups on PB8/PB9
  • TIM3 CH3 PWM output for the pump
  • GPIO pins and NUCLEOlabels COMfor integrationthe pathHX711 load cells and the flow sensor

What Is Not Yet Fully Modeled in CubeMX (TO-TO DO ONCEonce sensors are retrieved and assembled)

  • DedicatedADC ADCperipherals and channels for the analog sensors (pH, loadpressure/FSR); cell,PD14 pressure)and PD15 must also be moved to ADC-capable pins
  • DedicatedEXTI4 I2C/SPIrising-edge busesinterrupt for IMUthe andflow pressure variants
  • Explicit sensor-specificsensor pin labelsPA4 and(until alternate-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

  1. Open components/sensor_board/firmware/firmware.ioc in STM32CubeMX.
  2. Add the required peripheralsperipheral for the target sensor like(ADC this:
channel,
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)
    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/Ethernet and RTOS timing remainsremain stable.Generate code with Keep User Code enabled.Rebuild using PlatformIO and validate startup +and sensor polling.

    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)