System stuck when using STM32 HAL lib and Mbed together

Hello, I am using Mbed to develop a software for an industrial analog sampler(It has the same MCU with Nucleo H743ZI2). Everything works fine, but the environment requests the sampler to periodically sample analog signal (2kHz+). In this case, I consider using DMA, Timer, and ADC to maximize the performance. I have done the following things:

  1. Generate the code in CubeMX. I use ADC1 (Triggered by Timer 6 Event Update, and send the data to DMA1 Stream 7) and ADC2 (Triggered by Timer 15 Event Update, and send the data to DMA2 Stream 7)
  2. Compile and validate the code from CubeMX. Everything works as expected. I can see data in the buffer.
  3. Migrate the code to Mbed. Specifically, I did things listed as follows:
  • Disable the pin function in mbed that may collide with ADC1 and ADC2
  • Copy every MX_XXX_Init() functions related to ADC, DMA, and TIM to Mbed
  • Copy DMA and ADC interrupt handler to Mbed (In stm32h7xx_it.c and stm32h7xx_it.h)
  • Copy Msp_Init function to Mbed (In stm32h7xx_hal_msp.c)
  • Do everything mentioned in this link, including peripherals, clock and IRQHandlers.

The code passed the compilation and download, but when timer was going to generate an interrupt, system halted. The serial port printed:
Error Status: 0x80010133 Code: 307 Module: 1
Error Message: Mutex: 0x2400242C, not allowed in ISR context

Please give me some ideas on solving that, thanks!

1 Like

Hi Ivean,

I would take a look at your IRQ handlers as this " Error Message: Mutex: 0x2400242C, not allowed in ISR context" says you are using a Mutex within one of them (which is not thread safe and thus not allowed).


I have checked the code and finding that I call printf and other functions in ADC interrupt handler for debug reason (Which is not allowed). Now I trimmed the interrupt handler and moved most of the job into an EventQueue. Now everything works fine and thanks for your help.