Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Hardware SPI to MMC card?

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 15 September 2006, 0:03 AM    Post subject: Hardware SPI to MMC card? Reply with quote

I have a functioning bit-bang interface to a MMC card. I want to see if I can get it faster with hardware SPI. But the MMC cards seem to need pretty low level ability to interract with the SPI pins.

1) For instance, to initialize the MMC card, you are supposed to send 10 bytes with the CS pin DESELECTED.

I assume that other transactions on the SPI bus will have MORE that 10 bytes sent (i.e. to the EEPROM), so this part is probably already done for me.

But how do I _ensure_ that there were 10 bytes-worth of clocks with CS deselected? Do I define another SPI channel with pin 0 as the CS pin, then send 10 bytes on the dummy channel?



2) Similarly, when all the transactions are done, then CS is deselected and a byte is sent over the SPI bus. Do I do this the same way?



3) does anyone have experience with sharing the SPI bus with something like the EEPROM? Does the MMC card object to CS being deasserted after the card is initialized, but before other MMC transactions like a read or write?

-Tony
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 15 September 2006, 3:55 AM    Post subject: Reply with quote

Your idea of using an alternate SPI channel would seem to meet the requirements of both (1) and (2).

Regarding the CS going inactive, I expect that there are some "transactions", so to speak, that must be done while keeping CS asserted. I haven't looked at the SD/MMC protocol in detail but the EEPROM is like this. For example, you send it a Write command and an address and then you send it a series of bytes to be written. As long as you keep CS asserted you can keep writing bytes until the page limit is reached. At the page boundary you must deassert CS and then initiate another cycle (read or write). On Read cycles you can read continuously irrespective of the page boundaries.

The SD/MMC protocol may have similar sequences where you must keep CS asserted, others where you must deassert CS and still others where you may do either.
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 15 September 2006, 12:49 PM    Post subject: Reply with quote

DELETED BY AUTHOR - SEE NEXT POST

Last edited by spamiam on 15 September 2006, 12:58 PM; edited 1 time in total
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 15 September 2006, 12:57 PM    Post subject: Reply with quote

dkinzer wrote:
Your idea of using an alternate SPI channel would seem to meet the requirements of both (1) and (2).

Regarding the CS going inactive, I expect that there are some "transactions", so to speak, that must be done while keeping CS asserted. I haven't looked at the SD/MMC protocol in detail but the EEPROM is like this. For example, you send it a Write command and an address and then you send it a series of bytes to be written. As long as you keep CS asserted you can keep writing bytes until the page limit is reached. At the page boundary you must deassert CS and then initiate another cycle (read or write). On Read cycles you can read continuously irrespective of the page boundaries.

The SD/MMC protocol may have similar sequences where you must keep CS asserted, others where you must deassert CS and still others where you may do either.


I agree. I became very concerned about the need of ZX hardware to interleave EEPROM accesses when I realized that the way to put the MMC card into idle mode is to de-assert CS and clock 8 bits. This is exactly what will happen during an interleaved EEPROM access.

I suppose that the only way to get the MMC card to hapily share the SPI bus is to add extra hardware to insulate the card FROM the bus.

I was thinking that one could program a MMC_CS pin separately, and then feed the SPI CLK, MOSI, MISO pins to AND gates. The other input to the AND gates comes from the SPI CS pin thru an inverter.

This way the MMC card stays selected for as long as the MMC_CS pin remains low, but it will only see the SPI activity when the SPI CS pin is low (inverted to high before it reached the AND gates).

Do you think this will work? Is there an easier way to do it? This technique jumped to my mind because I have a few AND gates and Inverters sitting in a box at home.

-Tony
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 15 September 2006, 21:41 PM    Post subject: Reply with quote

spamiam wrote:
I suppose that the only way to get the MMC card to hapily share the SPI bus is to add extra hardware to insulate the card FROM the bus.

It may be necessary to do this but I would be suprised to find that it is so. Designing a chip with an SPI interface that cannot coexist with other SPI devices seems pointless.

spamiam wrote:
I was thinking that one could program a MMC_CS pin separately, and then feed the SPI CLK, MOSI, MISO pins to AND gates. The other input to the AND gates comes from the SPI CS pin thru an inverter.

If it is necessary, it may be simpler to use half of a quad 2-1 multiplexor. With the "select" signal in one state the SCLK and MOSI signals would be fed through to the device and in the other, they would be held in their inactive states. In either event, you'd probably have to use a flip-flop to synchronize the change of the select state so that you don't generate a glitch on the SPI clock signal. The MISO signal should not need any switching since it shouldn't be driven except by a device that is selected.
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 15 September 2006, 22:46 PM    Post subject: Reply with quote

You are right, it DOES seem pointless to be unable to share the SPI bus.

I will try to see how it works as-is running off the SPI bus, knowing that it will enter an idle state between MMC accesses.

I am just sure what the significance of going idle is.....

The manufacturers are not very free with their info about the functions of the SD/MMC cards.

I am especially interested in trying to get it to work w/o support logic for 2 reasons. 1) simplicity, 2) I only have 4000-series logic on hand, except inverters! They are rather SLOW! As I look at the SPI clock activity with my scope, I see that the 7MHZ clock frequency is painfully close the the max bandwidth of the AND gate I am testing! The specs say that rise time is 100uS. MAX speed would be 10Mhz, and probably half that is better.

I will try checking other forums about sharing the SPI bus.

-Tony
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group