cancel
Showing results for 
Search instead for 
Did you mean: 

Errors in SDMMC (STA and IDMABSIZE) registers / STM32cubIDE SFRs for STM32L4R9 ?

gorgabab
Associate

Hello

A few days ago, I went through the SDMMC registers using stm32l4r9-discovery.
I am using the "June 2021 RM0432 Rev 9" and haven't found a more recent datasheet for it.

Using stm32cubeide (1.17.0) (window->show view->)SFRs panel, the bits shown in SDMMC1 STA don't match with the datasheet ones in 54.10.11 SDMMC_STAR section as follow. The IDMA labels are missing too in SFRs.

comp_sfr_ds_sdmmc_sta.png

In 54.10.17 (p. 2030/3000), the IDMABNDT attribute is defined for the [12:5] bits (8-bit long value).
On the bit table, the 16th bit is shown as "rw" which is false as the [31:13] are specified as "reserved, must be kept at reset value". (In some stm32 boards, the sdmmc IDMABNDT is defined on [5:16] bits so it just might be a copy-paste error).

My main concerns about this register are the differences between the datasheet and HAL function.

The datasheet specifies a constant bit offset 5 for IDMABNDT, but in the HAL function, the IDMABSIZE is set depending on the BLOCKSIZE (constant 512 bytes) which is unclear/confusing to me.

Let's say My IDMA buffers are 10-block long.
Using datasheet, we have

SDMMC1->IDMABSIZE = ((SDMMC1->IDMABSIZE & 0xffffe01f) | (10 << 5)); // 0xffffe01f is the mask to prevent writes outside [12:5] // value is 8-bit long value
// = 320UL


Using HAL_SDEx_ConfigDMAMultiBuffer, we have

SDMMC1->IDMABSIZE = (uint32_t) (BLOCKSIZE * 10);
// = 5120UL (12 bits long starting to 0 which means a larger number of block would exceed the initial mask [12:5])


The results differ. My tests using the datasheet method worked but not the HAL ones where IDMABSIZE register would still be stuck at 0 after initialization (the mask might block the operation or something), thus blocking the HAL_SDEx_WriteBlocksDMAMultiBuffer operation.

gorgabab_1-1737558264752.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @gorgabab,

 

Thank you for bringing this issue to our attention. I reported this internally.

Internal ticket number: 202191 (This is an internal tracking number and is not accessible or usable by customers

Thank you for your contribution in STCommunity.

Kaouthar

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.

View solution in original post

2 REPLIES 2
KDJEM.1
ST Employee

Hello @gorgabab,

 

Thank you for bringing this issue to our attention. I reported this internally.

Internal ticket number: 202191 (This is an internal tracking number and is not accessible or usable by customers

Thank you for your contribution in STCommunity.

Kaouthar

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.

Hello,

Thank you for your answer.
Having forgotten about my post, I also forgot to correct an element concerning the IDMABSIZE thing.

I think I was partially wrong about my example.

Let's say my IDMA buffers are 10-block long.

Using HAL_SDEx_ConfigDMAMultiBuffer, we have :

IDMABSIZE = 10 * BLOCKSIZE; // = 5120 // byte long buffer, BLOCKSIZE not editable by user


Using the datasheet, we would take our buffer size (10 * my_blocksize) and convert it to fit the IDMABNDT 8-bit slot.
So we would have (in case of my_blocksize = 512) :

int my_blocksize = 512; // used for SDMMC CTRL reg DBLOCKSIZE config & can be changed
IDMABSIZE = (10 * 512 / 8 / 4) << 5; // = 5120 // ("/8/4" from the small explanation in IDMABDNT).

The HAL config is equivalent to the register manual config in the case of my_blocksize = BLOCKSIZE = 512 bytes.
However, the 2 methods should differ if we set a different blocksize value (my_blocksize =/= BLOCKSIZE).

The confusion also lies here :
The user can change the block size through sdmmc command (register CTRL ; DBLOCKSIZE). But the user cannot change the BLOCKSIZE constant of 512 bytes used in HAL libs, parameter that also cannot be changed in CUBEMX (only in optional FatFS / FileX).

Also, the HAL_SDEx_ConfigDMAMultiBuffer doesn't mention an idma buffer size limit which could led to errors if the user doesn't have a look in the datasheet (max size is 255 * 8 * 4 = 8160 bytes).

 

(I was wrong once, I can be wrong twice lol)