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

Writing MCI FIFO - LPC2368

Hi

Im trying to write in MCI FIFO but without success..

Im doing like:

MCI_DATA_CTRL = 0x11;
_printf("\r\nFIFO_COUNTER = 0x%X", MCI_FIFO_CNT);
MCI_FIFO |= 0xFFFFFFFF;
_printf("\r\nFIFO = 0x%X", MCI_FIFO);
_printf("\r\nFIFO_COUNTER = 0x%X", MCI_FIFO_CNT);

The answer I got is:

0 0
0

Do not show up the data that i wrote in MCI FIFO!
Im using LPC2368.

Waiting for a help!

Thank you,

Fabio.

  • What makes you think that you can write to MCIFIFO and then read back the same value?

    The user manual says that you can configure the FIFO for transmit or receive mode. But where does it say that in transmit mode, you can read back your writes.

    There is a sentence "The receive and transmit FIFOs can be read or written as 32 bit wide registers."

    But it never claims readback support. Only that the receive FIFO can be read and the transmit FIFO can be written.

    Next thing - should you prepare your data before trying to start a transfer?

    The data length register has a note "To initiate a data transfer, write to the data timer register and the data length register before writing to the data control register."

    Just so we know - have you read through the chapter about MCI? All of it? Have you moved back to the start of the chapter and read it again since you would now have learned all the terms you would need just to be able to understand the text?

    Or have you set a course for an iterative trial-and-error approach?

  • I didn't copy all code here. I write the line to print FIFO but now and I understand that's wrong. But the principal for me it's fifo counter, that remains at 0!.
    In my code I have the data timer and data length set too.

    Another thing I want to know it is if I can write in FIFO simply that way
    "MCI_FIFO |= 0xFFFFFFFF;"

    Sorry for my poor english..

  • MCI_FIFO |= 0xFFFFFFFF;
    


    This is a read/modify/write operation.

    Once again - why do you think that you can read from a transmit FIFO?

    About your counter problems - we most certainly can not comment on your problems if you only decide to rip some random lines from your code and post here. It really isn't practical to try to guess what lines you may have above or below your posted lines - or if your posted lines is even a perfect copy of a single block of lines from your code.

    But you have noticed this, from the user manual: "The FIFOs contain 16 entries on 16 sequential addresses. This allows the microprocessor to use its load and store multiple operands to read/write to the FIFO."

    So are you assigning one entry, or an array of entries? And exactly what do you do with the data length register? And when, in relation to your use of the data control register?

    And next thing. The description for the data counter register says: "As data is transferred, the counter decrements the value until it reaches 0."

    So if you want to see a non-zero value there, you must make sure you look when there is a transfer ongoing, and that transfer have data still to send.

    I ask again: Have you read through the full SD/MMC chapter at least twice?

  • Ok,let me try again.

    To initiate the card I used the mci_init() from Keil/NXP driver.
    Now just for test, I want to write a simple data in the card like ' 0 x FF FF FF FF '. 4 bytes.

    One thing I dont understand about MCI FIFO, the normal config in SD card is to set card block lenght to 512 bytes. It is quite confusing for me, all the time we have some lenght to set in code and the datasheet is not clare about that.
    SHould I change this config of 512B blocks?

    For example:
    I want to write 0xFF FF FF FF - 4 bytes

    So should I

    MCI_DATA_TMR = 0x10000000;
    MCI_DATA_LEN = 0x04; // Lenght of my data in FIFO
    MCI_DATA_CTRL = 0x91; // 9 = 10^9 = 512 = block size
    MCI_FIFO |= 0xFFFFFFFF;

    And now I call

    mci_cmd_write_block (0, 1) // This function set the argument 0 and writes 1 block
    // and send the command to the card

    What is missing? What is wrong?

  • Now, you really, really, really have to spend significant time trying to describe exactly why you see a need for a bit-or operation when writing to the FIFO.

    Why, just why do you write:

    MCI_FIFO |= 0xFFFFFFFF;
    

    And where have you seen the datasheet tell you that it is OK to perform a read operation from an output FIFO? You do know what the C operator |= does, don't you?

    Did you remember my comment, mentioned earlier - and copied from the processor user manual - about the order of assign to registers?

    The user manual says that when you write 0x01 to the data control register, the transfer will start. But what transfer? Do you really believe that you have set up all information needed for performing a transfer befure your line:

    MCI_DATA_CTRL = 0x91; // 9 = 10^9 = 512 = block size
    

    How can you start a transfer, on the line _before_ you assign your first data to the FIFO? And how can you start a transfer, _before_ you tell the chip how much data that is available in the FIFO for processing?

    The user manual says that when you enable the transfer, the controller will enter state WAIT_S or WAIT_R.

    For the Data Counter Register, the manual says that the register loads its value from the Data Length Register when the DPMS moves from IDLE to WAIT_R or WAIT_S. But have you spent any time giving the Data Length Register any length value for use? Where?

    Do you have a personal policy to avoid reading datasheets/user manuals? Does this policy often work well for you? Or does it happen, now and then, that you get stuck, because nothing works?

    By the way: how can you write this comment: "9 = 10^9 = 512 = block size"
    I would have thought that 10^9 would be 1,000,000,000. Wouldn't 512 be 2^9?

  • I would have thought that 10^9 would be 1,000,000,000. Wouldn't 512 be 2^9?

    Well, as the writing on the T-Shirt goes:

    There are 10 types of people in the world:

    those who can read binary, and all the others.

    ;->

  • It was clearly a type mistake, it's just you see that the result is right.

  • And the datasheet is confuse..
    We have Command Path State Machine (CPSM) and Data Path State Machine (DPSM).
    But dont help to the sequence..

    So..I follow CPSM steps and send the write command. I wait for an answer and if it's OK
    I go to DPSM?
    And then I prepare all registers, lenght, timer, FIFO.. Then I put 0x1 in Data_Control and the data is sent?

  • So what is the right way to put data in MCI FIFO?
    If I cant assign a direct data like this:
    MCI_FIFO = 0xFF;

    How can I do?

    Now my status is no longer 0

    It is 0x45000
    bits
    12 - TxActive
    14 - TxFIFO Half Empty
    18 - TxFIFO Empty
    are asserted

    So the problem Im having is with this damn FIFO.
    I dont understand how I can write in FIFO
    If I have to write a full 512B block and FIFO size its smaller.