cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing SD Mass Storage Memory on STM3210B-EVAL

james239955_stm1_st
Associate II
Posted on March 18, 2008 at 07:04

Accessing SD Mass Storage Memory on STM3210B-EVAL

22 REPLIES 22
james239955_stm1_st
Associate II
Posted on May 17, 2011 at 12:22

Thanks for the info Bart. Been off-line for the last couple of days so I will check out your links. Be nice to have some ready-written code for the STM32...

James

lanchon
Associate III
Posted on May 17, 2011 at 12:22

my $.02:

those that want to communicate to an embedded system via USB mass storage must keep in mind that most file systems (FATs, indeed) don't allow concurrent low-level access to the media. this means that the embedded system *cannot* read the files on the memory while it's mounted on the PC via USB MS. the unit must be safely stopped first, otherwise you'll see a corrupted file system due to caching issues at different levels. (but you could access the files via the host file system, using something similar to codesourcery's ''hosted'' option, but it would be too complex and fragile IMHO.)

16-32micros
Associate III
Posted on May 17, 2011 at 12:22

Hi all,

You can have a look on this thread on our STR7 Forum,

http://www.st.com/mcu/forums-cat-6208-17.html

a FAT demo is already done for STR7, the port to STM32 is very easy , just you need to update the SPI routines as the ones done on STM32 Evaluation USB Mass storage example. Enjoy it 🙂 Regards, STOne-32.

joneuhaus
Associate II
Posted on May 17, 2011 at 12:22

Hi,

Does anybody have port the FAT file system from the STR7?

I have actually to deal with it, so it would be helpful if someone has already port everything.

Thank you in advance.

PS: if nobody has done it, I will do it and release it on the forum.

joneuhaus
Associate II
Posted on May 17, 2011 at 12:22

The port was really simple. 8-)

You will find enclosed the files modified.

You need to simply add the usb_* and stm32f10x_* lib.

Enjoy... :D

frank5
Associate II
Posted on May 17, 2011 at 12:22

Hi joneuhaus,

Thanks for the port!

Can you please post how did you handle the Timer1,

in void T0OC1_IRQHandler(void) ?

Thanks,

Frank

viktor3
Associate II
Posted on May 17, 2011 at 12:22

Check this :http://elm-chan.org/fsw/ff/00index_e.html

frank5
Associate II
Posted on May 17, 2011 at 12:22

Thanks joneuhaus for the additional info!!

One more question:

Who is calling the disk_timerproc found in mmc.c ??

Thanks,

Frank

joneuhaus
Associate II
Posted on May 17, 2011 at 12:22

Instead of using the Timer1, I use the systick with a 1ms time base.

Here are the 3 functions to put in main.c :

/*******************************************************************************

* Function Name : SysTick_Config

* Description : Configure a SysTick Base time to 10 ms.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void SysTick_Config(void)

{

/* Configure HCLK clock as SysTick clock source */

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

/* SysTick interrupt each 100 Hz with HCLK equal to 72MHz */

SysTick_SetReload(720000);

/* Enable the SysTick Interrupt */

SysTick_ITConfig(ENABLE);

}

/*******************************************************************************

* Function Name : Delay

* Description : Inserts a delay time.

* Input : nCount: specifies the delay time length (time base 10 ms).

* Output : None

* Return : None

*******************************************************************************/

void Delay(u32 nCount)

{

TimingDelay = nCount;

/* Enable the SysTick Counter */

SysTick_CounterCmd(SysTick_Counter_Enable);

while(TimingDelay != 0)

{

}

/* Disable the SysTick Counter */

SysTick_CounterCmd(SysTick_Counter_Disable);

/* Clear the SysTick Counter */

SysTick_CounterCmd(SysTick_Counter_Clear);

}

/*******************************************************************************

* Function Name : Decrement_TimingDelay

* Description : Decrements the TimingDelay variable.

* Input : None

* Output : TimingDelay

* Return : None

*******************************************************************************/

void Decrement_TimingDelay(void)

{

if (TimingDelay != 0x00)

{

TimingDelay--;

}

}

The prototype of the functions Systick_Config and Delay have to be declared on top of the main.c.

You need to declare a public variables in main.c :

static vu32 TimingDelay = 0;

You have to declare the prototype of Decrement__TimingDelay in main.h and modify the interrupt handler in stm32f10x_it :

/*******************************************************************************

* Function Name : SysTickHandler

* Description : This function handles SysTick Handler.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void SysTickHandler(void)

{

/* Decrement the TimingDelay variable */

Decrement_TimingDelay();

}

This is more documented in the example of the systick (available on the website).

Hope it helps... :D

joneuhaus
Associate II
Posted on May 17, 2011 at 12:22

According to the str711 example, the disk_timerproc function is called in the Timer1 interrupt.

So in our case, it should be called in the systick interrupt (each 10ms).