SPI to MMC interface

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I'm trying to interface a ATmega128 to a MMC (MultiMediaCard) via the SPI port direct. Not through any additional external hardware or through a serial interface.

I can initalize the SPI port and write/transmit out the SPI port. I monitor it with a scope. The clock SCK is active during transmit and the SS line goes low to enable the receiving device. I send a reset command (40-00-00-00-00-95h) to the MMC card to place the card in SPI mode, and follow that up with a several status commands (41-00-00-00-00-xxh). Sometimes I get a reply, which I monitor with the scope, but it is reading the data back in that I'm finding difficult.

I read the SPDR port which should be reading in the most recent value out of the serial shift register. The value I'm expecting back is the status of the last command in R1 format, a single 8 bit byte containing possible error codes rom the MMC for the last command received.

To properly read do I wait for a SPIF flag (SPSR bit 7)? If the SPDR port is a bidrectional port used for both read and write data, is the SPIF flag used to inidicate a complete transmission and a complete reception?

Also to complete a 8bit transfer from the Atmega128 to a Slave SPI device it is necessary to have SS low and SCK active for a set number of cycles after trnsmision to allow for the recieving device to read it into it's register and generate a response. How do I keep clock active from ATmega128, (the Master), with sending a command?

Thanks for anyones help

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See the AVR academy application id 0021 by Sean Ellis.
It has well commented assembly code for reading, writing and initializing
a MMC card using the SPI interface.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

James,

thanks for the help. At first glance it looks like an ATMEL part tied to a RS232 device with an MMC plugged into the RS232 device. But on further examination the ATMEL is the RS232 device and the MMC card is plugged into the ATMEL.

Thanks,
Dean

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not too familiar with MMC and SD cards, but I thought they were pretty similar. Is it possible to interface an SD card to the AVR in the same way as with an MMC card?

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. You can interface a SD card to an AVR. The SD card is thicker
than the MMC and has added pins. You must use an SD socket in order
to accept both MMC and SD cards. SD cards will not fit in MMC sockets.
You can ignore the additional pins on the SD card and just use the MMC
pins for interfacing to the AVR. SD cards are downward compatible with
the older MMC cards.

Note that MMC cards are becoming rare and -- perhaps -- obsolete.
SD sockets are difficult to get in small quantities right now.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgilles584 (james gilles wrote:
See the AVR academy application id 0021 by Sean Ellis.
It has well commented assembly code for reading, writing and initializing
a MMC card using the SPI interface.

this sounds really useful for my project, but i cannot for the life of me find it. is it gone or am i just blind?

The downside to being better than everyone else is that people tend to assume you're pretentious.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How do I keep clock active from ATmega128, (the Master)

You don't. The SPI slave cannot send data unless the master clocks the CLK pin. Usually the master sends a dummy value in order to read what comes out from the slave, that's why you are reading the last command you send.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isnt the newer/bigger MMC cards 3v3 only ???

Can they be tied directly to a M128 ??? (Assuming its NOT an L)

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bingo600 wrote:
Isnt the newer/bigger MMC cards 3v3 only ???

Can they be tied directly to a M128 ??? (Assuming its NOT an L)

/Bingo

as far as i know they're all 3.3V. there have been a few threads about this before https://www.avrfreaks.net/phpBB2/viewtopic.php?p=120644#120644 is one.

does anyone know anything about the asm code for using an mmc that was mentioned? i looked all through the academy and couldnt find it.

The downside to being better than everyone else is that people tend to assume you're pretentious.