2025-08-05 10:48 AM
Hello everyone,
I'm working on a project using a NUCLEO-H7S3L8 board, and I have run into a very persistent and unusual problem involving FreeRTOS and a HAL function that I hope the community can provide some insight into.
My aim is to build an event-driven data acquisition system. The application uses multiple peripherals (ADC, SPI, UART, I2C, and TIM3 for PWM Input Capture) running in DMA mode. A central FreeRTOS task (StartOSScheduler) waits on an event group for any peripheral DMA to complete. When an event occurs, it collects data from all sources, aggregates it, and sends it as a UDP packet using LwIP.
My application halts without any fault or error when calling HAL_TIM_IC_Start_DMA() inside my main scheduler task (StartOSScheduler).
This proves that the peripheral clocks, GPIOs, timer configuration, and DMA configuration are all fundamentally correct. The issue is strictly related to the FreeRTOS task execution context.
I have spent a significant amount of time debugging this and have ruled out all the common causes. Here is what has been tried and confirmed:
Note: LED_GREEN turns on before the MCU gets stuck, LED_BLUE never turns on.
/*INSIDE FREERTOS.c*/
void MX_FREERTOS_Init(void) {
periodicADCTimerHandle = osTimerNew(PeriodicADCTimerCallback, osTimerPeriodic, NULL, &periodicADCTimer_attributes);
OSSchedulerHandle = osThreadNew(StartOSScheduler, NULL, &OSScheduler_attributes);
sysAliveHandle = osThreadNew(StartSysAlive, NULL, &sysAlive_attributes);
peripheralEventGroupHandle = osEventFlagsNew(&peripheralEventGroup_attributes);
}
void StartOSScheduler(void *argument)
{
MX_LWIP_Init();
osTimerStart(periodicADCTimerHandle, 60000U);
BSP_LED_On(LED_GREEN);
HAL_TIM_IC_Start_DMA(&htim3, TIM_CHANNEL_1, (uint32_t *)pwm_ch1_dma_buffer, PWM_DMA_BUFFER_SIZE);
BSP_LED_On(LED_BLUE);
HAL_TIM_IC_Start_DMA(&htim3, TIM_CHANNEL_2, (uint32_t *)pwm_ch2_dma_buffer, PWM_DMA_BUFFER_SIZE);
HAL_TIM_IC_Start_DMA(&htim3, TIM_CHANNEL_3, (uint32_t *)pwm_ch3_dma_buffer, PWM_DMA_BUFFER_SIZE);
HAL_SPI_Receive_DMA(&hspi1, (uint8_t*)spi1_dma_buffer, SPI_DMA_BUFFER_SIZE);
HAL_SPI_Receive_DMA(&hspi2, (uint8_t*)spi2_dma_buffer, SPI_DMA_BUFFER_SIZE);
HAL_UART_Receive_DMA(&huart4, (uint8_t*)uart4_dma_buffer, UART_DMA_BUFFER_SIZE);
HAL_UART_Receive_DMA(&huart5, (uint8_t*)uart5_dma_buffer, UART_DMA_BUFFER_SIZE);
HAL_UART_Receive_DMA(&huart7, (uint8_t*)uart7_dma_buffer, UART_DMA_BUFFER_SIZE);
HAL_I2C_Slave_Receive_DMA(&hi2c2, (uint8_t*)i2c2_dma_buffer, I2C_DMA_BUFFER_SIZE);
HAL_I2C_Slave_Receive_DMA(&hi2c3, (uint8_t*)i2c3_dma_buffer, I2C_DMA_BUFFER_SIZE);
....
Did anyone encounter this behaivior before or found a workaround? I inclluded the IOC as well as documentation about my config as appendix.
2025-08-05 10:59 AM
> My application halts without any fault or error
Where does execution stop? Show a stack trace. Hit run, let it encounter the problem, then hit pause. Probably it's stuck within interrupts somewhere.