This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SD CARD FIFO

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!

Parents Reply Children
  • Why does it look weird?

    What is the definition of MCI_FIFO ?

  • "The receive and transmit FIFOs can be read or written as 32 bit wide registers. The FIFOs
    contain 16 entries on 16 sequential addresses."

    I'm trying to use pointer, arrays without success..
    If anyone knows, please just help me..


  • Show what you've done.

    Explain what you expected it to do.

    Explain what it actually did.

    Explain what thoughts you've had to correct the situation.

    These are the basic steps of Debugging.

    Debugging is an essential skill that you need to learn - so you might as well start practising now!

    Here's some tips:

    www.8052.com/.../120313

    www.eetimes.com/.../Developing-a-good-bedside-manner

    Note that you still haven't said what specific chip you're using!

  • "Note that you still haven't said what specific chip you're using!"

    Note that a "Fabio Afellay" did mention LPC2368 in another thread just the day before this thread about the same thing. So either same person with aliases, or two school mates. Same problem and even same bugs in the posted source code.

    http://www.keil.com/forum/19529/

  • I use LPC2368.
    I need to write data in MCI_FIFO

    #define MCI_FIFO       (*(volatile unsigned long *)(MCI_BASE_ADDR + 0x80))
    

    MCI_FIFO has 16 sequencial positions (32 bits) starting in this adress.

    I need do put 32 bit data in each one of this 16 adresses.
    If I make the following code:

    MCI_FIFO = 0x1234;
    

    Of course, it will write just in the first one.

    What I have to do to put data in those 16 adresses?
    MCI_FIFO[1], MCI_FIFO[2]..
    That does not work...

  • You never did consider that I basically gave you the solution to your problem in a previous post?

    An "int" data type can't be indirected.

    But a pointer works with addresses.

    And you do know the address of your FIFO.

    And you should know how to index relative to a pointer.

    So have you tried yet?

    If this is hard for you, then you just have to spend some hours with a good C book. You just have to know how to work with pointers and arrays. If you do, then you would also know how to work with your FIFO.

    And if you had followed my suggestions about looking at sample code, you would also have gotten the idea that if DMA can use the FIFO, then maybe memcpy() could too. So you would suddenly have had a second alternative. Besides using DMA yourself, which would have been a third alternative.

    The problem? You jump to a conclusion. Test. Fail. Come directly to this forum. Never ponder why you fail, and if you can do better by taking one step back, turn slightly and then try again to walk forward and hopefully find the open door.

  • MCI_FIFO[1], MCI_FIFO[2]..
    That does not work...

    So you need to think about why that does not work!

    This is basic 'C' programming: what type(s) of items can be used with [] as an "offset" or "index" operator...?

  • Yes, my methods do work.

    It's just you who have decided that "my methods" means something else than they do.

    An integer is an integer. Just a number without any fractional parts.

    An integer variable has an address and can store an integer.

    An integer variable can not be used as a base for indexing. After all, it is not an array but an integer variable.

    The address of an integer variable is a pointer.

    A pointer can be used for indirection.

    A pointer to an integer variable can be used for indexing integer values.

    A pointer can also be used for memcpy().

    This is covered early on in books for learning C. Why start with a memory card program, until you have learned basic C data types, and how they relate to each other? As you have already noticed, you get really frustrated when you get stuck at every step. Not our fault, but caused by you trying to reverse the order of things. You try to write poetry before you have learned how to read and write. You try bike racing before you have learned how to keep the balance on a bicycle.

    Doing things in the correct order, means you can feel good when you have managed to master something new. Every step you manage is a level up. Doing it the reverse way is just leading to frustration. Fighting the end boss before you are geared up just results in wipes. You fail. You have to restart. You fail again. New restart. New fail. Repeat until you give up. Because that is the end result if skipping the basics. Instead of seeing LEGO pieces that can be combined, you see black voodoo magic.

    Any help we give you, will only get you one puny step forward, before you get stuck again. And again. And again. To get forward, you must learn what LEGO pieces you have available, and how they can be combined.

  • You're all so smart!!
    And neither you know how to solve the problem! kkk
    Congratulations!

  • You're all so smart!!<

    You have no idea.

    And neither you know how to solve the problem! kkk

    And you really believe you are in a position to be the judge of that?

    Congratulations!

    You can keep those to yourself, thank you very much. Nobody wants to be congratulated by you.

  • Do you actually want to learn how to do this stuff for yourself - or not?

    If you're not interested in doing this stuff, that's fair enough - it's not for everybody - but that's no reason to expect others to do it for you for free.

    I am not interested in doing accountancy, so I pay an acountant to do that stuff for me - but I don't expect him to do it for me for free!

  • 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.