Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32H7 CUBEMX SD Card FATFS NVIC problem #305

Open
vahidajalluian opened this issue Jan 14, 2025 · 8 comments
Open

STM32H7 CUBEMX SD Card FATFS NVIC problem #305

vahidajalluian opened this issue Jan 14, 2025 · 8 comments
Assignees
Labels
bug Something isn't working cube mx Issue related to the Cube MX tool rather than the firmware published within this repository needs clarification Needs clarification or inputs from the user sdmmc Secure Digital input/output Multimedia Card interface

Comments

@vahidajalluian
Copy link

Following the request in this issue, I have created this one.

Describe the set-up
I am using a custom board with the following specifications:

MCU: STM32H743BIT6
STM32CubeMX version: 6.13
H7 firmware version: V1.12.0

Describe the bug
When one creates a project from scratch with stm32cubemx this issue will happen.

Enabling SDMMC and Fatfs, I could not make it work and emulate the SDCARD. However, in the F4 series program I had earlier, I saw that it was forcibly enabled NVIC, so I enabled the NVIC and the problem was solved.

@ALABSTM ALABSTM added bug Something isn't working cube mx Issue related to the Cube MX tool rather than the firmware published within this repository sdmmc Secure Digital input/output Multimedia Card interface labels Jan 15, 2025
@KRASTM
Copy link
Contributor

KRASTM commented Jan 16, 2025

Hello @vahidajalluian,

Thank you for the report.

Could you please, share your .ioc file, and more details about the error?

With regards,

@KRASTM KRASTM added the needs clarification Needs clarification or inputs from the user label Jan 16, 2025
@vahidajalluian
Copy link
Author

I will share a checked ioc to reproduce the issue by sunday. I am not at work these two days.

@KRASTM KRASTM moved this from To do to Analyzed in stm32cube-mcu-fw-dashboard Jan 20, 2025
@KRASTM
Copy link
Contributor

KRASTM commented Feb 3, 2025

Hello @vahidajalluian,

Any news please?

With regards

@vahidajalluian
Copy link
Author

vahidajalluian commented Feb 3, 2025 via email

@vahidajalluian
Copy link
Author

@ALABSTM @KRASTM
Here is the example code with IOC that doesn't force activation of NVIC. Sorry for being (too much) late
sdTest.zip

@KRASTM
Copy link
Contributor

KRASTM commented Feb 7, 2025

Hello @vahidajalluian,

Regarding your issue, I think there is a misunderstanding. The SDMMC driver supports 3 modes: polling, interrupt and DMA like almost all IP, for the NVIC and as mentioned in the brief of the driver file, it enabled when interrupt process used.

(#) Initialize the SDMMC low level resources by implementing the HAL_SD_MspInit() API:
(##) Enable the SDMMC interface clock using __HAL_RCC_SDMMC_CLK_ENABLE();
(##) SDMMC pins configuration for SD card
(+++) Enable the clock for the SDMMC GPIOs using the functions __HAL_RCC_GPIOx_CLK_ENABLE();
(+++) Configure these SDMMC pins as alternate function pull-up using HAL_GPIO_Init()
and according to your pin assignment.
(##) NVIC configuration if you need to use interrupt process (HAL_SD_ReadBlocks_IT()
and HAL_SD_WriteBlocks_IT() APIs).
(+++) Configure the SDMMC interrupt priorities using function HAL_NVIC_SetPriority();
(+++) Enable the NVIC SDMMC IRQs using function HAL_NVIC_EnableIRQ()
(+++) SDMMC interrupts are managed using the macros __HAL_SD_ENABLE_IT()
and __HAL_SD_DISABLE_IT() inside the communication process.
(+++) SDMMC interrupts pending bits are managed using the macros __HAL_SD_GET_IT()
and __HAL_SD_CLEAR_IT()
(##) No general propose DMA Configuration is needed, an Internal DMA for SDMMC Peripheral are used.

I tried the same config with F4 Serie, and I didn't find that it was forcibly enabled NVIC, I think it's a choice for the user to enable or not NVIC and may depend on the application.

If you could share your API sequence used in your project for further analysis, otherwise you can check examples and/or application with DK and Eval boards under projects for further details.

With regards,

@vahidajalluian
Copy link
Author

@KRASTM Thank you for your follow up
My mistake about activating NVIC forcibly, but if I don't activate it, It wont work with Fatfs, and reason is unknown for me.
Image

@KRASTM
Copy link
Contributor

KRASTM commented Feb 10, 2025

Hello @vahidajalluian,

Since your application includes other IP such as USB and ADC beside SDMMC and FATFS as described in #304, also you do not activate NVIC for SDMMC (in other word you work with polling mode), maybe another interrupt is the source of your problem and to get it to work you need to enable NVIC.

I suggest you only test SDMMC and FATFS to be sure, otherwise if you could share with us your sequence and perhaps some details in debug mode.

With regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cube mx Issue related to the Cube MX tool rather than the firmware published within this repository needs clarification Needs clarification or inputs from the user sdmmc Secure Digital input/output Multimedia Card interface
Projects
Development

No branches or pull requests

3 participants