2021-06-23 08:01 AM
Hi,
I'm using an STM32H7A3ZI MCU, with freeRTOS, fatFS & DMA
I have set the SDMMC2 peripheral with 4 bit mode & DMA (by default in STM32H7 MX config). I have implemented the code from this example to test my SD card (microSDHC 32Gb, also test on 2Gb SD).
I set the example code inside a RTOS task (1024 stack size) (CubeMX detects that I use RTOS so the sd_diskio file is set for rtos with queues and so, however I didn't implement queues in the example code)
My problemen is that at the HAL_SD_InitCard part, I have and HardFault_Handler error at this line :
>>> HAL_Delay(1U + (74U * 1000U / (sdmmc_clk)));
(in stm32h7xx_hal_sd.c)
On the hardware part I have 47k pullup on data & CMD pins, the voltage supply is OK. I try also without the 47k pullup & with internal pull up. I have set the SD clock to 12.5Mhz.
Any idea on what could cause this problem ?
You can find my full code here:
https://github.com/pa0694/IOC_SDMMC
Thanks!
Solved! Go to Solution.
2021-06-24 01:06 AM
Hi Tesla, thanks for your answer.
Indeed, with further investigation I notice that it comes from freeRTOS. I raised the priority of the SDMMC task and the hardfault dissapears... to now lead to a MemManage_Handler error (still using freeRTOS). I need to find a good template example with SDMMC & freeRTOS, as I'm not quite sure of my code.
But I can confirm that without freeRTOS, the SDMMC periphal is working !
2021-06-23 08:46 AM
Try having a proper Hard Fault Handler, and unpacking the fault state, the registers, and the disassembly to better understand the nature of the fault.
Initial thought it might be a divide by zero, but that seems to have been checked earlier.
Perhaps the fault is not quite where you think it is due to optimization or code movement. Try turning optimization off on the routine, but more specifically look at the low level code the MCU is actually executing rather than the high level stuff.
2021-06-24 01:06 AM
Hi Tesla, thanks for your answer.
Indeed, with further investigation I notice that it comes from freeRTOS. I raised the priority of the SDMMC task and the hardfault dissapears... to now lead to a MemManage_Handler error (still using freeRTOS). I need to find a good template example with SDMMC & freeRTOS, as I'm not quite sure of my code.
But I can confirm that without freeRTOS, the SDMMC periphal is working !
2024-09-02 03:17 AM
I have a similar problem and the HAL_SD_InitCard() uses the HAL_Delay() but the SysTick is not running since RTOS is active.
The IOC configuration with RTOS and SDMMC insert the call to MX_SDMMC1_SD_Init() before the initialization of RTOS.
2024-12-03 04:28 PM
Did you ever find a good example?
How did you raise priority of the SDMMC, Mine is locked to >=5