cancel
Showing results for 
Search instead for 
Did you mean: 

Understand SD Card detect pin initialization

DYann.1
Senior II

Hello,

I would like to understand the code to carry out my software integration :

 

    /* Configure SD pin detect */
    __SD_DETECT_GPIO_CLK_ENABLE();
    __HAL_RCC_PWR_CLK_ENABLE();

 

And This refers to lines of code that I am lost, for the first line for example

 

#define __SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()

 

And after :

 

#define __HAL_RCC_GPIOG_CLK_ENABLE()           do { \
                                                    __IO uint32_t tmpreg; \
                                                    SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
                                                    /* Delay after an RCC peripheral clock enabling */ \
                                                    tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
                                                    UNUSED(tmpreg); \
                                                  } while(0)

 

I would just like to configure the SD card to be able to write the code from an example on the evaluation card. My real card is not the evaluation card and I would like the code just necessary. Do you have an example for STM32L5xx with the file .ioc for example.

Thank you 

 

 

33 REPLIES 33

@DYann.1 wrote:


I would like to take just a portion of code necessary to work on my real card 


I would start by cutting-down your EV code to just your minimum required for the SD Card.

When you have that working, port that onto your own board.

Thank you for your answer but I don't really know how to understand how it works on the evaluation card (since I have a program that already works). What I need is to work on my own board with only the STM32L552ZET6QU microprocessor.

 

How to start with a new configuration via STM332CubeIDE (without the BSP and files linked with the evaluation card)

DYann1_0-1736261140100.png

I have a version that works but not all the time and I don't know where this could come from.


@Andrew Neil wrote:

I would start by cutting-down your EV code to just your minimum required for the SD Card.


This point is very difficult for me without the '.ioc' file because there are too many references in standard definitions, function calls, etc. This quickly becomes incomprehensible

SofLit
ST Employee

As you are using CubeMx I invite you to watch that video especially at 5:59 on how to configure SDcard pin detection on CubeMx.

Hope that gives you more visibility on the subject.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@DYann.1 wrote:

 I don't really know how to understand how it works on the evaluation card


In order to port code, you really do need to understand how it works!

As suggested earlier, I would start by cutting down the EV code to just that necessary for the SD card part.

Study the code to see how it works.

Add status prints to a UART so you can follow its execution.

You can also use the debugger to follow execution - but that risks disrupting critical timing, which can break things...

 

Have you looked to see if there is an SD Card example for the Nucleo-L552? If there is, it is likely simpler than an EV example which also does all sorts of other things...


@DYann.1 wrote:

@Andrew Neil wrote:

I would start by cutting-down your EV code to just your minimum required for the SD Card.


This point is very difficult for me without the '.ioc' file because there are too many references in standard definitions, function calls, etc. This quickly becomes incomprehensible


Yes but to do things well you need to do more efforts to understand what is going on in the background. This is not the Arduino environment :).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@DYann.1 wrote:

@Andrew Neil wrote:

I would start by cutting-down your EV code to just your minimum required for the SD Card.


This point is very difficult for me without the '.ioc' file because there are too many references...


The .ioc file is irrelevant here.

Look at the source code as it is - it should be easy enough to follow through and see what's related to SD Card, and what isn't.

 


@Andrew Neil wrote:

The .ioc file is irrelevant here.

Look at the source code as it is - it should be easy enough to follow through and see what's related to SD Card, and what isn't.


Did you see the start of my topic ? For 1 line of code there are 4 or 5 references and it becomes unreadable. Of course, putting the code on the SD card is easy when you know it, but when you start, for me it is better to start with CubeMX and eventually complete it later.


@Andrew Neil wrote:

Have you looked to see if there is an SD Card example for the Nucleo-L552? If there is, it is likely simpler than an EV example which also does all sorts of other things...


I'm going to look at this track which seems more accessible to me


@DYann.1 wrote:

@Andrew Neil wrote:

The .ioc file is irrelevant here.

Look at the source code as it is - it should be easy enough to follow through and see what's related to SD Card, and what isn't.


Did you see the start of my topic ? For 1 line of code there are 4 or 5 references and it becomes unreadable. Of course, putting the code on the SD card is easy when you know it, but when you start, for me it is better to start with CubeMX and eventually complete it later.


CubeMx helps you to speed up the development but needs from you to understand what you are doing.

Did you watch the video of the card detection config with CubeMx that I shared in a previous comment?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.