Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21608 Discussions

Read data from a SD card using an Altera Max II

Altera_Forum
Honored Contributor II
2,430 Views

Hi, I want to create a little board that has a Max II cpld and a Sd Card. The Max II version I´m using is Epm240t100c5n. 

I want to handle the Sd cart like a normal flash chip, so I need to pass some address, like 0x12345, and read a byte from this position from the Sd card.  

I´ll get the addresses from some I/O pins in the Max II, and I´ll put the 8bits that I read from Sd in another I/Os. 

And besides reading the Sd card I need implement in Max II some other logic. 

 

So, the Altera Max II can handle this stuff? Is there an easy way to implement this Sd interface? 

 

I found in internet some pictures of little circuits with an Max II and a Sd card, so seems to be possible. But I need a little help to start. 

Someone knows what I have to do? 

 

Thanks........
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,520 Views

Max II will handle the physical interface nicely - you'll be able to interface the SD card directly to I/O pins of the CPLD. However, the EPM240 isn't a particularly large part - it's internal resources are relatively limited. So, you'll be limited on how much functionality you can squeeze into it. 

 

Based on what you describe, I suspect the EPM240 will have enough logic available for you to realise your goal. 

 

 

--- Quote Start ---  

Is there an easy way to implement this Sd interface? 

--- Quote End ---  

If you know what you're doing... I'm not sure how to answer that question without knowing how you intend to implement it. Can I assume you'll be writing some rtl? 

 

Cheers, 

Alex
0 Kudos
Altera_Forum
Honored Contributor II
1,520 Views

Hi, thanks for your answer.  

 

I need only to read from the Sd card. And I want to read raw data, so I don´t need any type of filesystem in the Sd card, like Fat16/32. In the cpld I´m assuming the card was previously filled with the raw data I want to access. 

So what I want is to receive an address and read the Sd card to retrieve the byte in that address. 

 

So I need some ideas on how implement this. In the Sd protocol can I access individual raw bytes from any address or can I only retrieve blocks? Other question is if the EPM240 has enough logic to implement this kind of work, but from what you said it probably has. 

 

About writing some rtl, probably I´ll need to implement code from scratch. I don´t have much experience with cpld/fpga, but I think I can handle myself with hdl code in stuff not so complex.  

 

If you have more information please let me know.  

 

Thanks, 

Doug
0 Kudos
Altera_Forum
Honored Contributor II
1,520 Views

Yes, I think the EPM240 will have enough logic for this. By removing much of the intelligence from the CPLD, more or less limiting it's function to the Physical layer (Phy) of the solution, you should end up with enough logic. 

 

As for the interface, have a look at this web page: how to use mmc/sdc (http://elm-chan.org/docs/mmc/mmc_e.html). It covers the basics, everything you've suggested you need. 

 

In considering your solution you will need to issue more than one command to the SD card - you can't 'just read' from it as soon as it's powered. You'll need to issue other commands prior to this. So, make sure your solution is flexible enough to allow you to issue different commands. 

 

Cheers, 

Alex
0 Kudos
Reply