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!

  • Didn't you see it as a hint when the manual claims that MCI_FIFO is an array?

    Don't you think reading the relevant chapter of the user manual is a far faster way?

  • Yeah, with 16 positions of 32bits each one.
    But I dont understand about it.. How can I write in a memory area like this?
    I DONT KNOW HOW TO DO THIS!!
    It is an array, ok and what I do with this?

    Im not a super! If I'm having some doubt this is the place to ask for help or not?
    It is not easier you help instead of criticizing?

    Thank you

  • Yeah Per Westermark,

    Us ejats need your support not your criticism.

    Thank you very much.

  • MCI_FIFO is an array ..... How can I write in a memory area like this

    if you do not know how to write to an array, you need to learn C, before you jump into a project. This is elementary C.

    Erik

  • The purpose of this forum is stated here:

    "The Keil Discussion Forum is an open forum where you may post questions and comments about Keil products"

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

    So, strictly speaking, it's not intended as a place to come for basic 'C' training, and it's not really a place to ask questions about the details of other manufacurer's products.

    Take a look at the Support and Events sections - there are links to books, training providers, etc,...

    There's also a consultants database: http://www.keil.com/condb

  • But you have seen C arrays before?

    You have used C arrays before?

    You know about the similarity (similar - not identical) between pointers and arrays?

    That arr[15] can access an array element and *(ptr+15) can do a similar thing?

    That pointer indirection is possible with an array and array indexing is possible with a pointer?

    And you know the address of this FIFO array?

    So how would you then be able to gain access to the individual entries of the FIFO?

    By the way - just as I have asked a couple of times about reading the datasheets and user manuals, there is something else. What about sample code and application notes? Have you looked for them? Have you taken any closer look? Note that you may then also find sample code that is instead using the FIFO for DMA transfers. But code that is performing real tasks based on the user manual is still good to read - an alternative "view" of the documentation.

    I guess you have not spent much time with C, since you spent quite a number of posts with |= to assign to the FIFO. Something I guess you did pick up from some other sample source code lines - source code lines that did turn on flags in R/W-capable registers.

    If you need to get the basics of C programming, it's way easier to start on a PC. It has a huge bandwidth available for printing trace output or letting a graphical debugger show the internals of your program.

  • I know what an array is, but I dont understand about arrays in this context:
    should I use MCI_FIFO[0], MCI_FIFO[1],...?
    It will work?

    I guess it looks weird to me..

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