cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103VC with MMCCard

nafb
Associate II
Posted on September 01, 2014 at 17:11

Hi,

I want to use 512 Mb MMC card with STM32F103VC.

Hardware is ok . Do you have any ideas on this issue? any driver for STM.

How can I read and write file in MMC card ? 

Regards,

5 REPLIES 5
Posted on September 02, 2014 at 02:42

STM32F10x_StdPeriph_Lib_V3.5.0\Utilities\STM32_EVAL\Common\stm32_eval_sdio_sd.c

STM32F10x_StdPeriph_Lib_V3.5.0\Utilities\STM32_EVAL\Common\stm32_eval_spi_sd.c

FatFs ?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nafb
Associate II
Posted on September 02, 2014 at 22:18

Thanks a lot. I'll try them.

I want to do

.

values

​​into

a file named

test.txt

to save

.

for example

,

in

the test.txt file

data

will be

as follows:

Row 1:

0123456789012

Row 2:

0123456789012

Row 3:

0123456789012

.........

.........

.........

.........

Row n

:

0123456789012

Posted on September 02, 2014 at 22:33

Ok, so if you understand how to work with strings, sprintf(), and STDIO you should be golden.

FRESULT res;
FIL fil;
FATFS fs32;
memset(&fs32, 0, sizeof(FATFS));
res = f_mount(0, &fs32);
#ifdef DBG
if (res != FR_OK)
printf(''res = %d f_mount
'', res);
#endif
memset(&fil, 0, sizeof(FIL));
if (f_open(&fil, ''LOG.TXT'', FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
{
UINT BytesWritten;
const char string[] = ''Another line gets added

'';
f_lseek(&fil, fil.fsize); // Seek to end
f_write(&fil, string, strlen(string), &BytesWritten);
f_close(&fil);
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nafb
Associate II
Posted on September 04, 2014 at 00:17

I tested it.

/*-----------------------------------------------------------------------*/

/* Initialize a Drive                                                    */

/*-----------------------------------------------------------------------*/

DSTATUS disk_initialize (  BYTE drv /* Physical drive number (0..) */ )

{

.....

.....

for (n = 10; n; n--) xchg_spi(0xFF); /* Send 80 dummy clocks */

.....

.....

/*-----------------------------------------------------------------------*/

/* Exchange a byte */

static BYTE xchg_spi ( BYTE dat /* Data to send */ )

{

printf(''\n\rBYTE xchg_spi_SPI1->DR: %d'',dat);

SPI1->DR = dat;

while (SPI1->SR & _BV(7)) ;

return (BYTE)SPI1->DR;

}

/*-----------------------------------------------------------------------*/

it shows at Hyper terminal ;

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

and restart  STM32F103VC

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

BYTE xchg_spi_SPI1->DR: 255

Do you have  any  suggestion ?

Posted on September 04, 2014 at 05:56

Do you have  any  suggestion ?

Well you'd want to start with the hardware, pins/interfacing. Make sure the drivers have been suitably ported to your board.

Review how the card responds to commands.

Test/validate the sector read/write functionality.

Integrate into FatFs.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..