SDMMC_BLOCK error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User14606
Level 1
Level 1
Hi all,

since updating Dave 4.3.2 with the current Dave Apps and XMCLib (2.1.18) I've got a problem with FATFS->SDMMC_BLOCK->SPI_MASTER. When I try to compile I get the following errors:

"SDMMC_BLOCK requires XMC Peripheral Library v2.1.20 or higher" <-- and this is crazy, because it was an official update package from the infineon homepage....
and
"SDMMC_BLOCK_SDV2_CSD_t' has no member named 'dev_size_high"

After installing Dave 4.4.2 with XMCLib version 2.1.20 I still get the message "SDMMC_BLOCK_SDV2_CSD_t' has no member named 'dev_size_high"

The error occurs in function: SDMMC_BLOCK_SPI_GetSectorCount

What is wrong in these libraries?


Thanks and regards
Stefan
0 Likes
3 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Could you replace SDMMC_BLOCK_SPI_GetSectorCount() in Dave/Generated/SDMMC_BLOCK/sdmmc_block_private_spi.c until we release a new version of the APP:

SDMMC_BLOCK_MODE_STATUS_t SDMMC_BLOCK_SPI_GetSectorCount(SDMMC_BLOCK_t *const obj, uint32_t *sector_count)
{
uint32_t multiplier = 0U;

if (((uint32_t)obj->card_type & (uint32_t)SDMMC_BLOCK_CARD_TYPE_HIGH_CAPACITY) != (uint32_t)0)
{
SDMMC_BLOCK_SDV2_CSD_t *tmp_csd = (SDMMC_BLOCK_SDV2_CSD_t *)&obj->sdmmc_spi->card_info.csd;

/*
* For High Capacity SD card, (C_SIZE field value + 1) * 1024
* gives the sector count
*/
*sector_count = (uint32_t)(((uint32_t)tmp_csd->dev_size + (uint32_t)1) << (uint32_t)10);
}
else
{
SDMMC_BLOCK_SDV1_CSD_t *tmp_csd = (SDMMC_BLOCK_SDV1_CSD_t *)&obj->sdmmc_spi->card_info.csd;

/* Left Shift evaluates 1* 2^(TmpMmcCsd.DeviceSizeMult + 2)*/
multiplier = (uint32_t)(((uint32_t)tmp_csd->dev_size_mult + (uint32_t)tmp_csd->read_blk_len) - (uint32_t)7);
/* Sector Count = Device_size * Mult.*/
*sector_count = (uint32_t)((uint32_t)tmp_csd->dev_size + (uint32_t)1) << multiplier;
}

return SDMMC_BLOCK_MODE_STATUS_SUCCESS;
}
0 Likes
User14606
Level 1
Level 1
Hey Jesus,

works now. Thank you very much!

Regards,
Stefan
0 Likes
User14606
Level 1
Level 1
Hello Jesus,

the problem why i wanted to update the Apps and the Libs is still there. Im Using a XMC1402-F064 and want to write data to a SD card. I used the infineons example code to do this:

if(status == DAVE_STATUS_SUCCESS)
{
/* Register work area */
res = f_mount(&fs, "0:", 1);

if (res == FR_OK)
{
/* Create a new directory */
res = f_mkdir("XMC4500");

if ((res == FR_OK) || (res == FR_EXIST))
{
/* Create a file as new */
res = f_open(&fil, "XMC4500/hello.txt", FA_CREATE_ALWAYS | FA_WRITE | FA_READ);

if ((res == FR_OK) || (res == FR_EXIST))
{
/* Write a message */
res = f_write(&fil, "Hello, World!\r\n", 15, &bw);

if (res == FR_OK )
{
res = f_lseek(&fil, 0);
/* Read the buffer from file */
res = f_read(&fil, &buff[0], 15, &br);

if(res == FR_OK)
{
/* Go to location 15 */
res = f_lseek(&fil, 15);

if(res == FR_OK)
{
/* Add some more content to the file */
res = f_write(&fil, "\nWelcome to Infineon", 20, &bw);

if(res == FR_OK)
{
f_close(&fil);
}
}
}
}
}
}
}
}

1. Sometimes I just get a FR_NOT_READY as result from f_mount, but the MCU is still running.

2. In most cases the MCU stucks in "sdmmc_block_private_spi.c" at line 1514: spi_status = SPI_MASTER_Receive(obj->spi_master_handle, response_data, num_of_bytes);
while (obj->spi_master_handle->runtime->tx_busy == true)
{ }

3. But sometime everything works at the first call of the example code (files are created with content), but if I try to append data to the file the MCU stucks (like in 2.) while calling f_open


I've been trying to write data to the card for some days now with any success. To you have any suggestions?


Regards,
Stefan
0 Likes