2025-01-07 03:17 AM - last edited on 2025-01-07 03:35 AM by Andrew Neil
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
2025-01-07 06:39 AM
@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.
2025-01-07 06:48 AM
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)
I have a version that works but not all the time and I don't know where this could come from.
2025-01-07 06:54 AM
@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
2025-01-07 06:55 AM
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.
2025-01-07 06:58 AM
@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...
2025-01-07 07:00 AM
@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 :).
2025-01-07 07:01 AM
@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.
2025-01-08 03:47 AM
@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.
2025-01-08 03:50 AM
@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
2025-01-08 03:52 AM
@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?