Hello,
Im trying to implement a SD Card Interface. I'm having a doubt..
I´m able to initialize and write and read data. But it is so crazy the data I'm reading!! I try to write 0,1,2,3.... And when I read I dont get this sequence.
I guess the problem is the way I'm writing in MCI_FIFO.
When I'm writing I set all necessary registers (lenght, timer..)
And then I initialize the transfer:
MCI_DATA_CTRL |= 0x91;
Then how should I write the code to put data in MCI_FIFO?
IF I do a for like this:
for(x=0; x<128;x++) { MCI_FIFO = x; }
but it makes no sense, what is the right way to do this?
Help me!
I have done a "fill in lines between the numbered dots" for you.
You can solve it directly from my text. If you do known the syntax for pointer indirection, address-of operator, indexing, ...
If not, then it should be very easy to figure out what chapters to take a closer look at in a C self-study book.
It's just that it isn't meaningful to tell you how to perform indexed writes to the FIFO as a magical line. If you do not spend the time to understand why and what, then you will just get stuck again 5 seconds later.
Your question is a bit like "what is the product of 7 * 9?" A quite easy question. But if you don't understand multiplication, it will suddenly be a very hard question. And if someone do tell you the answer is 63, you would still be just as stuck, because you would still not understand how multiplication works.
So the solution to your problem is to send a couple of hours reading up on pointers and arrays. It would be well invested time. And you would need this knowledge anyway, to get through any real application. One reason for that is that pointers are so integral to C code. C makes use of pointers in many situations where other languages have more specialized ways of writing code.