EmbeddedRelated.com
Forums

Good SPI sample with MMC or SD card

Started by berserksemi February 9, 2006
Hi,

I'm trying to read and write on a MMC card with a RCM3700 dev kit and
the sample included with Dynamic C is not helping a lot so if any of
you have some tips or code sample it would be much appreciated.

Thanks!
	
--- In rabbit-semi@rabb..., "berserksemi" <yannickg@...>
wrote:
>
> Hi,
> 
> I'm trying to read and write on a MMC card with a RCM3700 dev kit and
> the sample included with Dynamic C is not helping a lot so if any of
> you have some tips or code sample it would be much appreciated.
> 
> Thanks!
>

Am I doing something wrong here or maybe asking too much or something
too complicated because I posted 2 messages and didn't get any
answers.  Don't get me wrong, I'm not complaining, I'm just
trying to
understand.

Thanks
Bye
	

I don’t really see a question or problem to answer.  So you are having trouble, we all have trouble.   What kind of trouble are you having?

 

If this is a “do my homework” question, or  “This is to hard somebody give me code” then you will not get an answer.

 

Ryan

 

 

From: r...@yahoogroups.com [mailto:r...@yahoogroups.com] On Behalf Of berserksemi
Sent: Wednesday, February 15, 2006 3:31 PM
To: r...@yahoogroups.com
Subject: [rabbit-semi] Re: Good SPI sample with MMC or SD card

 

--- In r...@yahoogroups.com, "berserksemi" <yannickg@...> wrote:
>
> Hi,
>
> I'm trying to read and write on a MMC card with a RCM3700 dev kit and
> the sample included with Dynamic C is not helping a lot so if any of
> you have some tips or code sample it would be much appreciated.
>
> Thanks!
>

Am I doing something wrong here or maybe asking too much or something
too complicated because I posted 2 messages and didn't get any
answers.  Don't get me wrong, I'm not complaining, I'm just trying to
understand.

Thanks
Bye




berserksemi wrote:
--- In r...@yahoogroups.com, "berserksemi" <yannickg@...> wrote:
Hi,
I'm trying to read and write on a MMC card with a RCM3700 dev kit and
the sample included with Dynamic C is not helping a lot so if any of
you have some tips or code sample it would be much appreciated.
Thanks!
Am I doing something wrong here or maybe asking too much or something
too complicated because I posted 2 messages and didn't get any
answers. Don't get me wrong, I'm not complaining, I'm just trying
to
understand.
The SPI driver in sflash.lib is a good start. My MMC driver was loosely based on the one that was ported at Softools then  optimized.

MMC is straightforward SPI. Just remember that you can't talk over 400khz until the card is out of the idle state

There was an article in in Circuit Cellar with sample code for accessing MMC/FAT. Much of My MMC driver comes from it. The basic MMC commands were used.

<Scott>

-- ------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns | PGP Key 0xE98DDC48 |
| http://www.shdesigns.org |
------
today's fortune They're giving bank robbing a bad name.
-- John Dillinger, on Bonnie and Clyde


I don't want anybody to do my homework, don't you think I did
much
research before finding this group ?  I didn't ask for a working
project, I asked for some tips from people who could have already gone
through where I am right now.

Yes it's hard but what I want is some help not someone making it for me.

After all what is the use of newsgroup if it's not to get help from
people who are better than ourselves.

--- In rabbit-semi@rabb..., "Ryan Alswede" <ryan.alswede@...>
wrote:
>
> I don't really see a question or problem to answer.  So you are having
> trouble, we all have trouble.   What kind of trouble are you having?
>  
> If this is a "do my homework" question, or  "This is to hard
somebody
> give me code" then you will not get an answer.
>  
> Ryan
>  
>  
> ________________________________
> 
> From: rabbit-semi@rabb... [mailto:rabbit-semi@rabb...]
> On Behalf Of berserksemi
> Sent: Wednesday, February 15, 2006 3:31 PM
> To: rabbit-semi@rabb...
> Subject: [rabbit-semi] Re: Good SPI sample with MMC or SD card
>  
> --- In rabbit-semi@rabb..., "berserksemi" <yannickg@>
wrote:
> >
> > Hi,
> > 
> > I'm trying to read and write on a MMC card with a RCM3700 dev kit
and
> > the sample included with Dynamic C is not helping a lot so if any of
> > you have some tips or code sample it would be much appreciated.
> > 
> > Thanks!
> >
> 
> Am I doing something wrong here or maybe asking too much or something
> too complicated because I posted 2 messages and didn't get any
> answers.  Don't get me wrong, I'm not complaining, I'm just
trying to
> understand.
> 
> Thanks
> Bye
> 
> 
> 
> 
> 
> 
> SPONSORED LINKS 
> Embedded module
>
<http://groups.yahoo.com/gads?t=ms&k=Embedded+module&w1=Embedded+module&
>
w2=Microcontrollers&w3=Z-world&w4=Intel+microprocessors&w5=Pic+microcont
> rollers&c=5&s9&.sig=PKF29LUPJhnpBsWg5J85HQ>  
> Microcontrollers
>
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Embedded+module
>
&w2=Microcontrollers&w3=Z-world&w4=Intel+microprocessors&w5=Pic+microcon
> trollers&c=5&s9&.sig=K41LzkC3YTQ4GbRLJ3KQ9A>  
> Z-world
>
<http://groups.yahoo.com/gads?t=ms&k=Z-world&w1=Embedded+module&w2=Micro
>
controllers&w3=Z-world&w4=Intel+microprocessors&w5=Pic+microcontrollers&
> c=5&s9&.sig=okV367Dggjlugt9Il5s5wg>  
> Intel microprocessors
>
<http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Embedded+m
>
odule&w2=Microcontrollers&w3=Z-world&w4=Intel+microprocessors&w5=Pic+mic
> rocontrollers&c=5&s9&.sig=pec2WtY94tDIRUZwZqbDMw>  
> Pic microcontrollers
>
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Embedded+mo
>
dule&w2=Microcontrollers&w3=Z-world&w4=Intel+microprocessors&w5=Pic+micr
> ocontrollers&c=5&s9&.sig=vYbE9aCBMq0yVnx-QhdR4w>  
>  
>  
> ________________________________
> 
> > . 
>  
> ________________________________
>
	
Thanks! I gave a look at circuitcellar.com and found some interesting
info.

--- In rabbit-semi@rabb..., Scott Henion <shenion@...> wrote:
>
> berserksemi wrote:
> > --- In rabbit-semi@rabb..., "berserksemi" <yannickg@>
wrote:
> >   
> >> Hi,
> >>
> >> I'm trying to read and write on a MMC card with a RCM3700 dev
kit and
> >> the sample included with Dynamic C is not helping a lot so if any
of
> >> you have some tips or code sample it would be much appreciated.
> >>
> >> Thanks!
> >>
> >>     
> >
> > Am I doing something wrong here or maybe asking too much or something
> > too complicated because I posted 2 messages and didn't get any
> > answers.  Don't get me wrong, I'm not complaining, I'm
just trying to
> > understand.
> >   
> The SPI driver in sflash.lib is a good start. My MMC driver was loosely
> based on the one that was ported at Softools then  optimized.
> 
> MMC is straightforward SPI. Just remember that you can't talk over
> 400khz until the card is out of the idle state
> 
> There was an article in in Circuit Cellar with sample code for accessing
> MMC/FAT. Much of My MMC driver comes from it. The basic MMC commands
> were used.
> 
> <Scott>
> 
> -- 
> ------
> | Scott G. Henion| shenion@... |
> |   Consultant   |   Stone Mountain, GA  |
> |   SHDesigns    |   PGP Key 0xE98DDC48  |
> |     http://www.shdesigns.org           |
> ------
> today's fortune 
> They're giving bank robbing a bad name.
> 		-- John Dillinger, on Bonnie and Clyde
>
	
At 01:21 PM 2/16/2006 +0000, you wrote:
 >
 >I don't want anybody to do my homework, don't you think I did
much
 >research before finding this group ?  I didn't ask for a working
 >project, I asked for some tips from people who could have already gone
 >through where I am right now.

I'll give you a nickels worth of free advice:

Pick a brand of card and stick with it.  I've had the best luck with 
Sandisk following the official spec.  There are a lot of generic branded 
cards that have weird startup issues, bizarre error codes, unsupported 
commands, etc.  If you can at all control what card gets used with your 
project, lock that down.

Some other things:

-bit order for the built in Rabbit SPI and MMC SPI is backwards
-erased bytes can be either 0x00 or 0xFF depending on card brand (see above)
-erasing an entire card is another problematic procedure in older 
cards.  The new SD cards seem to be fast, but I've had MMC cards take a 
couple minutes to delete.
-on commands that return a busy, wait a few clocks before you start 
checking for busy since it seems to take a few clocks before the card 
starts returning the correct state
-I played with the "streaming sector" read where you read multiple
sectors 
at a time, and found it to not be faster than reading consecutive 
individual sectors.  This may be a function of the slower Rabbit SPI 
implementation, but at least for me there was no significant time change.
	The MOST important thing is to make your code bulletproof.  Assume you're 
going to get garbage back sometimes.  Assume that the card will go away and 
not come back (IE make sure all your routines have timeouts).  It took me 
two weeks to get my code doing most of what it does now.  It took me two 
years to get it to reliably do it's job on most cards I throw at it.

Good luck!

-Mike
	
--- In rabbit-semi@rabb..., Mike van Meeteren <mike@...> wrote:
>
> At 01:21 PM 2/16/2006 +0000, you wrote:
>  >
>  >I don't want anybody to do my homework, don't you think I
did much
>  >research before finding this group ?  I didn't ask for a working
>  >project, I asked for some tips from people who could have already gone
>  >through where I am right now.
> 
> I'll give you a nickels worth of free advice:
> 
> Pick a brand of card and stick with it.  I've had the best luck with 
> Sandisk following the official spec.  There are a lot of generic
branded 
> cards that have weird startup issues, bizarre
error codes, unsupported 
> commands, etc.  If you can at all control what card gets used with your 
> project, lock that down.
> 
> Some other things:
> 
> -bit order for the built in Rabbit SPI and MMC SPI is backwards
> -erased bytes can be either 0x00 or 0xFF depending on card brand
(see above)
> -erasing an entire card is another problematic
procedure in older 
> cards.  The new SD cards seem to be fast, but I've had MMC cards take
a 
> couple minutes to delete.
> -on commands that return a busy, wait a few clocks before you start 
> checking for busy since it seems to take a few clocks before the card 
> starts returning the correct state
> -I played with the "streaming sector" read where you read
multiple
sectors 
> at a time, and found it to not be faster than
reading consecutive 
> individual sectors.  This may be a function of the slower Rabbit SPI 
> implementation, but at least for me there was no significant time
change.
> 
> 
> The MOST important thing is to make your code bulletproof.  Assume
you're 
> going to get garbage back sometimes.  Assume that
the card will go
away and 
> not come back (IE make sure all your routines have
timeouts).  It
took me 
> two weeks to get my code doing most of what it
does now.  It took me
two 
> years to get it to reliably do it's job on
most cards I throw at it.
> 
> Good luck!
> 
> -Mike
>

Awesome, thanks a lot!  That's exactly the kind of tips I want.

I'm computing all those information, so keep them coming! :-)
	
Hi,
You wouldn't happen to have the link to the article on circuitcellar.com?

Regards

-----Original Message-----
From: berserksemi [mailto:yannickg@yann...] 
Sent: Friday, 17 February 2006 12:39 AM
To: rabbit-semi@rabb...
Subject: [rabbit-semi] Re: Good SPI sample with MMC or SD card
	Thanks! I gave a look at circuitcellar.com and found some interesting info.

--- In rabbit-semi@rabb..., Scott Henion <shenion@...> wrote:
>
> berserksemi wrote:
> > --- In rabbit-semi@rabb..., "berserksemi" <yannickg@>
wrote:
> >   
> >> Hi,
> >>
> >> I'm trying to read and write on a MMC card with a RCM3700 dev
kit 
> >> and the sample included with Dynamic C is not helping a lot so if 
> >> any of you have some tips or code sample it would be much 
> >> appreciated.
> >>
> >> Thanks!
> >>
> >>     
> >
> > Am I doing something wrong here or maybe asking too much or 
> > something too complicated because I posted 2 messages and didn't
get 
> > any answers.  Don't get me wrong, I'm not complaining,
I'm just 
> > trying to understand.
> >   
> The SPI driver in sflash.lib is a good start. My MMC driver was 
> loosely based on the one that was ported at Softools then  optimized.
> 
> MMC is straightforward SPI. Just remember that you can't talk over 
> 400khz until the card is out of the idle state
> 
> There was an article in in Circuit Cellar with sample code for 
> accessing MMC/FAT. Much of My MMC driver comes from it. The basic MMC 
> commands were used.
> 
> <Scott>
> 
> --
> ------
> | Scott G. Henion| shenion@... |
> |   Consultant   |   Stone Mountain, GA  |
> |   SHDesigns    |   PGP Key 0xE98DDC48  |
> |     http://www.shdesigns.org           |
> ------
> today's fortune
> They're giving bank robbing a bad name.
> 		-- John Dillinger, on Bonnie and Clyde
>
	Yahoo! Groups Links
	
I don't know if it's the link that Scott was talking about but
here it
is : http://www.circuitcellar.com/pastissues/articles/Tom99/text.htm

--- In rabbit-semi@rabb..., "Craig Atkin" <craig@...> wrote:
>
> Hi,
> You wouldn't happen to have the link to the article on
circuitcellar.com?
> 
> Regards
> 
> -----Original Message-----
> From: berserksemi [mailto:yannickg@...] 
> Sent: Friday, 17 February 2006 12:39 AM
> To: rabbit-semi@rabb...
> Subject: [rabbit-semi] Re: Good SPI sample with MMC or SD card
> 
> 
> Thanks! I gave a look at circuitcellar.com and found some
interesting info.
> 
> --- In rabbit-semi@rabb..., Scott Henion <shenion@> wrote:
> >
> > berserksemi wrote:
> > > --- In rabbit-semi@rabb..., "berserksemi"
<yannickg@> wrote:
> > >   
> > >> Hi,
> > >>
> > >> I'm trying to read and write on a MMC card with a
RCM3700 dev kit 
> > >> and the sample included with Dynamic C is not helping a lot
so if 
> > >> any of you have some tips or code sample it would be much 
> > >> appreciated.
> > >>
> > >> Thanks!
> > >>
> > >>     
> > >
> > > Am I doing something wrong here or maybe asking too much or 
> > > something too complicated because I posted 2 messages and
didn't
get 
> > > any answers.  Don't get me wrong,
I'm not complaining, I'm just 
> > > trying to understand.
> > >   
> > The SPI driver in sflash.lib is a good start. My MMC driver was 
> > loosely based on the one that was ported at Softools then  optimized.
> > 
> > MMC is straightforward SPI. Just remember that you can't talk
over 
> > 400khz until the card is out of the idle state
> > 
> > There was an article in in Circuit Cellar with sample code for 
> > accessing MMC/FAT. Much of My MMC driver comes from it. The basic MMC 
> > commands were used.
> > 
> > <Scott>
> > 
> > --
> > ------
> > | Scott G. Henion| shenion@ |
> > |   Consultant   |   Stone Mountain, GA  |
> > |   SHDesigns    |   PGP Key 0xE98DDC48  |
> > |     http://www.shdesigns.org           |
> > ------
> > today's fortune
> > They're giving bank robbing a bad name.
> > 		-- John Dillinger, on Bonnie and Clyde
> >
> 
> 
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links
>