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.

Parents
  • 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?

Reply
  • 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?

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