cancel
Showing results for 
Search instead for 
Did you mean: 

Basic SDIO on F4 discovery board

chichkinei
Associate II
Posted on September 15, 2012 at 09:58

Can anyone please provide me with a link to some basic, low level, 4-bit SDIO interface code compatible with the STM32F4VGT? I'm not looking for it to support a file system(yet), I just want to be able to read bytes from a uSD card. I've seen a few examples out there but I don't understand enough about C to understand all the high level stuff, let alone figuring out how to get TrueSTUDIO to compile it.

#metoo
21 REPLIES 21
Andrew Neil
Evangelist III
Posted on October 05, 2012 at 08:41

''Without an oscilloscope I have no way of knowing...''

That should be written on a sticky note and posted on every microcontroller developer's screen!!

An oscilloscope really is a fundamental requirement for microcontroller development!

 

Trying to do microcontroller development without a 'scope is like trying to do carpentry without a saw.
chichkinei
Associate II
Posted on October 05, 2012 at 09:55

Well, I do what I can with what I have. Maybe instead of building a new computer I'll have to get myself a scope for new years! I seem to need it more and more for every project I work on.

frankmeyer9
Associate II
Posted on October 05, 2012 at 18:51

Maybe instead of building a new computer I'll have to get myself a scope for new years!

If you seriously want to get into embedded development (or electronics in general), you going to need it.

Perhaps you can try to go cheap and get a used scope.

Or something like the ARM DSO Nano.

And RIGOL, a chinese supplier, is pressing into the market with rather competitive (and cheap) scopes.

God beware the chinese one day decide to flood the western market with ARM Cortex controllers and boards ...

chichkinei
Associate II
Posted on January 06, 2013 at 08:24

Alright, time to bring this thread back to life. I got an oscilloscope (DS1052E) and I've been playing around with it, looking at SDIO data lines and what not. So far I've confir

med tha

t

the

wrong data is bein

g sent from the SD card to the MCU as opposed to from the MCU to the LCD. To prove this I

modifie

d the first 5 bytes of an image to

0xFF

00 FF 01 B4 and

probed data line

0

, which would give the LSB of each nybble

, which is as fol

lows: 11

00 11 01

10. When

the data is trans

fer

red correctly (the image on the LCD looks right) I get

the

above data on my scope (I was going to attach an image but th

is bloody forum software keeps giving me an

error

). And when the image

looks corrupte

d, the data on the scop

e looks wrong too. Keep in mind that all of this testing was done at a ~300

kHz SDIO clock. I don't really k

now what to make of this. Obviously the waveform is very clean so it can't be that the MCU is reading the data wrong

.

Curiousl

y, the LCD somet

imes just stops drawing part way through the transfer, yet the SD card continues to send data. If I

set the SDIO clock to a v

ery low va

lue,

then the

card stops sending data part way through.

chichkinei
Associate II
Posted on January 07, 2013 at 07:36

After a bunch of experimentation, using coax and a 10k pulldown on the clock line seems to have solved the problem for good! No idea why, but that's besides the point. It still looks like a sine wave on the scope though, maybe that's because it's only a 50 MHz scope.

Posted on January 07, 2013 at 20:25

My signal wires between boards are in the order 20-30 mm, which was about a short as I could do practically.

The code snippet you posted earlier is for the polling code, others seem to have had issues with that, I'm using the DMA code path.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chichkinei
Associate II
Posted on January 13, 2013 at 07:47

I assume using the DMA is faster? How much code would I have to change to implement it?

Also, did I mention I hate this forum software... 5'th time trying to post this

Posted on January 13, 2013 at 14:44

stm32f4_discovery_sdio_sd.h

..

/* Uncomment the following line to select the SDIO Data transfer mode */

#if !defined (SD_DMA_MODE) && !defined (SD_POLLING_MODE)

#define SD_DMA_MODE                                ((uint32_t)0x00000000)

/*#define SD_POLLING_MODE                            ((uint32_t)0x00000002)*/

#endif

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chichkinei
Associate II
Posted on January 14, 2013 at 04:02

I don't know where you found the Discovery header file, I sure went through hell trying to find an SDIO example for the Discovery and ended up using stm324xg_eval_sdio_sd.h instead. Either way, I just check and SD_DMA_MODE is defined, while SD_POLLING_MODE isn't. So I guess I am using DMA? Speaking of the DMA, I think I might have toastedpart of mine. I'm experimenting with the ADC DMA example for the Discovery and until recently it worked fine. Now however, the ADC gives me a value from 0-65520, whereas is used to give me 0-4095 as it should. It seems as if the data is being left-aligned (shifted 4 bytes left) even though I'm telling it to right-align. I didn't change any code either. It just randomly started doing this. I've tried a different ADC channel and a different DMA steam too.

Posted on January 15, 2013 at 17:57

I don't know where you found the Discovery header file, I sure went through hell trying to find an SDIO example for the Discovery and ended up using stm324xg_eval_sdio_sd.h instead.

I created it when I ported, and posted examples for the platform.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..