2018-08-01 07:43 AM
Hello,
I am a total newby for what concerns stm32 programming and this question may be stupid....
I am using a STM32H753i-eval board and will need to use fdcan, lcd, SD and a few more peripherals. For this reason I started my project using STM32cubeMX and the latest H7 1.3.0 STM32cube. I cleared all pins and tried to configure SDMMC1 as plain 1 bit.
As soon as I try to initialize the card, using HAL_SD_INIT(&hsd1), the program returns an error code.
I compared my code with the SD example in the cube library, and changed my clock settings to make them identical to those in the example (just in case!), but the init function still fails. I also disabled the DMA template in the FatFs setup, as suggested in another post, but still no success.
I used the debugger and found that the error is generated in
SDMMC_CmdOperCond()
called by SD_PowerON()
where
SD_CmdResponse7() returns SDMMC_ERROR_CMD_RSP_TIMEOUT;
this sets
hsd->SdCard.CardVersion = CARD_V1_X;
and finally, when
SDMMC_CmdAppCommand()
is called
SDMMC_GetCmdResp1()
returns, as the previous function, SDMMC_ERROR_CMD_RSP_TIMEOUT;
so that a final HAL_SD_ERROR_UNSUPPORTED_FEATURE; is returned to my main().
I did try to copy as much as possible the example (that works, even if quite slow) but with no success. Maybe I am just doing something stupid..... can anyone help ?
2018-08-01 07:44 AM
(btw, I am using System Workbench + eclipse, but maybe this is not relevant)
2018-08-01 08:57 AM
Make sure the transceiver is enabled in stm32h7xx_hal_conf.h
#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */
>>hsd->SdCard.CardVersion = CARD_V1_X;
I wager you don't have a 1.x card, so you're observing compounding failure.
>>Maybe I am just doing something stupid..... can anyone help ?
You're using CubeMX, so there's that to consider. ST has FAE's for commercial clients, and there are people willing to provide consulting.
2018-08-02 01:37 AM
Thank you very much !
Will try that as soon as I get back to office. I did notice that cubeMX does not always behave as in the user manual (e.g. .extSettings file does not seem to work, was trying to use that to import some files from the application examples in my project....).
2018-08-03 09:15 AM
Since you are using CubeMX are you using DMA for the transfers to and from the SD card?
If so, you may need to fix stm32h7xx_it.c.
1) change extern SD_HandleTypeDef hsd1; to point to uSDHandle
2) change the SDMMC1_IRQHandler() to pass &uSDHandle as the argument.
This is done so stm32h7xx_it.c is referencing the same structure as used in the HAL code.
DMA works if you remember to uncomment the cache maintenance define in sd_diskio.c created by CubeMX.
2018-08-03 09:23 AM
Also, if you are using the SD card detection you will need to add to stm32h7xx_it.c the handler that CubeMX leaves out. In the last user section add:
/* USER CODE BEGIN 1 */
/**
* @brief This function handles SD detection interrupty
* @param None
* @retval None
*/
void EXTI9_5_IRQHandler(void)
{
SD_DetectIRQHandler();
}
2018-08-03 12:38 PM
DMA is also predicated on the memory being used. The SDMMC1 internal DMA needs to go into the 0x24000000 region, it will hang up on 0x20000000..0x2001FFFF