May 07, 2020
05:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 07, 2020
05:53 AM
Hi everyone,
I've still got the problem that I can't write to a SD-card connected to a XMC1402 via SPI.
If I do the first writing (with the sample code) everything's fine. The directory will be created and the file incl. content will be written.
But if I try to open this file again later (append-mode) the system hangs in "sdmmc_block_private_spi.c" at line 1517: while (obj->spi_master_handle->runtime->tx_busy == true).
Does somebody have the same problem?
Best regards,
Stefan
switch(u8function)
{
case SD_INIT: 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("ZB");
if ((res == FR_OK) || (res == FR_EXIST))
{
/* Create a file as new */
res = f_open(&fil, "ZB/BATT.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 this Card", 20, &bw);
if(res == FR_OK)
{
f_close(&fil);
}
}
}
}
}
}
}
}
break;
case SD_APPEND: __NOP();
//res = f_mount(&fs, "0:", 1);
res = f_open(&fil, "ZB/BATT.TXT", FA_OPEN_APPEND);
if(res == FR_OK)
{
res = f_lseek(&fil, f_size(&fil));
f_printf(&fil, "\nTest");
}
f_close(&fil);
break;
default: break;
}
I've still got the problem that I can't write to a SD-card connected to a XMC1402 via SPI.
If I do the first writing (with the sample code) everything's fine. The directory will be created and the file incl. content will be written.
But if I try to open this file again later (append-mode) the system hangs in "sdmmc_block_private_spi.c" at line 1517: while (obj->spi_master_handle->runtime->tx_busy == true).
Does somebody have the same problem?
Best regards,
Stefan
switch(u8function)
{
case SD_INIT: 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("ZB");
if ((res == FR_OK) || (res == FR_EXIST))
{
/* Create a file as new */
res = f_open(&fil, "ZB/BATT.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 this Card", 20, &bw);
if(res == FR_OK)
{
f_close(&fil);
}
}
}
}
}
}
}
}
break;
case SD_APPEND: __NOP();
//res = f_mount(&fs, "0:", 1);
res = f_open(&fil, "ZB/BATT.TXT", FA_OPEN_APPEND);
if(res == FR_OK)
{
res = f_lseek(&fil, f_size(&fil));
f_printf(&fil, "\nTest");
}
f_close(&fil);
break;
default: break;
}
- Tags:
- IFX
0 Replies