This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1290NCPDT: How to send the I2C slave address in master mode using the FIFO?

Part Number: TM4C1290NCPDT
Other Parts Discussed in Thread: TM4C1294NCPDT

Dear community,

I am using the TM4C1294NCPDT in order to (among other things) read data from a magnetometer sensor using I2C.

Reading out the sensor with busy waiting works great, and I can also see the I2C clock and data line on a scope, so I am sure that the MCU, the sensor, and the printed circuit board are fine.

As I use the MCU to send the data using Ethernet, I want to use the FIFO and uDMA together with the I2C to be faster. For starters, I just use the FIFO (without the DMA).

My question is why the following code gives me two bytes of signal on the line (namely a "write to slave 0x0E" followed by the data byte 0x01)

// Set slave address for writing
I2CMasterSlaveAddrSet(I2C2_BASE, 0x0E, 0);

// Transmit a byte (place it in the I2C data register)
I2CMasterDataPut(I2C2_BASE, 0x01));
I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_SEND);

but the following code

// Set slave address for writing
I2CMasterSlaveAddrSet(I2C2_BASE, 0x0E, 0);

// use the FIFO to send 0x37 = 55
I2CFIFODataPutNonBlocking(I2C2_BASE, 55);
I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_FIFO_SINGLE_SEND);

only gives me 0x37 on the line (but not the byte which says "send to slave0x0E").

I already had a look at all the bits in the register description for I2CMSA, I2CMCS, and I2CMDR. Turns out that the only difference between the single send commands is that the BURST bit is set for the FIFO, and the RUN bit when I don't use the FIFO. This is in accordance with the datasheet. This should not affect putting the slave address on the line though, should it? I cannot find this information in the datasheet.

How can I make sure that even when I use the FIFO, the slave address is put on the line? After all I need this to talk to the specific slave.

Thank you!

  • Hello Philipp,

    Have you had a chance to go through our I2C app note? It is: www.ti.com/.../spma073.pdf

    Included in the software folder is an example with I2C master using uDMA and FIFO. I think this would be where you'd want to start.

    Looking at the example code provided and comparing it to yours, it looks like for FIFO operations the slave address is transmitted differently where instead they break up the addressing into upper and lower bits, and use the I2C_MASTER_CMD_BURST_SEND_START and I2C_MASTER_CMD_BURST_SEND_CONT options for the address transmission. Then FIFO related commands are used.

    The exact example I was looking at was ektm4c129_i2c_master_udma_fifo from the spma073 software file which I think will be a very useful reference for you.

    Reading through the app note as well, it seems using the non-FIFO commands is the way to go for the address in general, even if FIFO/uDMA is used. Though whether you really need to use the upper/lower bits like the software example I am not certain of, but in any case you should try setting your data transfer to replicate the example and go from there.
  • Hello Ralph,

    Thank you very much for the I2C app note pointer. I'm already working with that, I'm sorry for not pointing that out.

    Yes, the FIFA with uDMA example is great! In fact, I'd probably be lost completely without this example. However, this example just contains way too much to start with. Lacking the board which is used for the app note, it is impossible to just try it out, but just copying it for my example and adjusting some things --hoping everything works out-- does not work either. That's why I wanted to start simple, without the uDMA. The app note actually contains an example for only-FIFO as well.

    I think the upper/lower 8-bit thing just means that this is the data. The slave address is always 7-bit plus the Read/Write bit.

    But you are right: The slave address issue is always dealt with using the non-FIFA commands. So I think I just have to go that way as well. I was just interested in why this is the case.

    Thanks for answering. I'll accept this as the answer, if nobody can tell my "why" ;-)

    Best,
    --Philipp

  • Hello Philipp,

    Looking through the API's and the datasheet, I believe this is because the Slave Address is not something that would be loaded into the FIFO by TivaWare. Rather, it has it's own dedicated register (I2CMSA), so therefore when using the I2CMasterSlaveAddrSet API, the slave address register is loaded into that register and it must be transmitted from the I2C Master as a normal I2C byte, not out of the FIFO.
  • Thank you Ralph for having a look at it again.
    Yes, I agree. This is also what I observed on my device.
    Best,
    --Philipp