cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 + SDMMC + IDMA + CMD18 ( SD/SDHC Card with FATfs ) - Strange data in bufer after each sector

kons
Associate

Hello.

Has anyone successfully read data from an SD card using CMD18 ( READ_MULTIPLE_BLOCK ) SDMMC in STM32U5?

... or ...  Can anyone confirm that these microcontrollers have a manufacturing error in SDMMC operation?

IDMA from SDMMC reads data into the buffer.
Reading a single sector (512B) using CMD17 ( READ_SINGLE_BLOCK ) works correctly ( in 1bit or 4bit mode ) ...  but i can't read MULTIPLE_BLOCKS correctly ...
On the memory card I have a text file with the following content:

:00000001 abcdefghijklmnoprstuwxyz
:00000002 abcdefghijklmnoprstuwxyz
:00000003 abcdefghijklmnoprstuwxyz
:00000004 abcdefghijklmnoprstuwxyz
:00000005 abcdefghijklmnoprstuwxyz
:00000006 abcdefghijklmnoprstuwxyz
:00000007 abcdefghijklmnoprstuwxyz
:00000008 abcdefghijklmnoprstuwxyz
:00000009 abcdefghijklmnoprstuwxyz
:00000010 abcdefghijklmnoprstuwxyz
:00000011 abcdefghijklmnoprstuwxyz
:00000012 abcdefghijklmnoprstuwxyz
:00000013 abcdefghijklmnoprstuwxyz
:00000014 abcdefghijklmnoprstuwxyz
:00000015 abcdefghijklmnoprstuwxyz
:00000016 abcdefghijklmnoprstuwxyz
... etc ...

The buffer content after reading by "CMD18 ( READ_MULTIPLE_BLOCK )" is as follows:
1. The first 512B (sector) is correct
2. 14 or 15 (depending on the settings clock) strange Bytes, I don't know what they are
3. Depending on the card model I have the next 512 Bytes correct or incorrect
4. again 14 or 15 strange Bytes,
5. next 512B correct
6. again 14 or 15 strange Bytes
... and so on until the end of the buffer/file
I am pasting a screen of the buffer contents.

1 ACCEPTED SOLUTION

Accepted Solutions
kons
Associate

Problem solved, I misunderstood the meaning of SDMMC_DCTRL_DBLOCKSIZE in the SDMMC2->DCTRL register. :grinning_face_with_sweat:
I entered the amount of data I want to read instead of the sector size (512B), so 9 should be entered in the register. An example of a correct line below:
SDMMC2->DCTRL = (9<<SDMMC_DCTRL_DBLOCKSIZE_Pos) | SDMMC_DCTRL_FIFORST | SDMMC_DCTRL_DTDIR | (0<<SDMMC_DCTRL_DTMODE_Pos) ;

( Can I somehow delete this post or leave it for others? )

View solution in original post

1 REPLY 1
kons
Associate

Problem solved, I misunderstood the meaning of SDMMC_DCTRL_DBLOCKSIZE in the SDMMC2->DCTRL register. :grinning_face_with_sweat:
I entered the amount of data I want to read instead of the sector size (512B), so 9 should be entered in the register. An example of a correct line below:
SDMMC2->DCTRL = (9<<SDMMC_DCTRL_DBLOCKSIZE_Pos) | SDMMC_DCTRL_FIFORST | SDMMC_DCTRL_DTDIR | (0<<SDMMC_DCTRL_DTMODE_Pos) ;

( Can I somehow delete this post or leave it for others? )