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.

MSP432 I2C Master Problem

Hi there,

i am trying to use the I2C Bus to programm the Slave(Clock Generator).

I have pulled both SCL and SDA wires  to 10kOhm and +3V3.

Problem is that the Master is not sending the correct "Slave Adress" to the slave.

I have also disconnected the wires going to the slave and measure it again and having the same results.

I did a screen shot from the SDA and SCL that was sended from the MSP432(Master):

So as far as i understood the Master starts with the START bit by pulling SDA to Low and starts the SCL Clock.

Than sends the SLAVE ADRESS so the Slave knows the message its for him. His adress its 0xD4.

So by reading the SDA i see 0xA8 and not 0xD4. 

At the end of course the Slave will not pull the SDA down to Acknowledge, it stays High for None Acknowledge, or becouse the Slave knows his not the one been spoken to.

Here is also my setup code:

Any idea?

  • I forgot to say that the SDA/SCL screenshot came from the
    MAP_I2C_masterSendStart(EUSCI_B3_MODULE);
    and the second one
    MAP_I2C_masterSendMultiByteNext(EUSCI_B3_MODULE, SLAVE_ADDRESS);
    didnt send any messages out.

    The first masterSend sends the Start and Slave Adress bit, the second one was only for testing
  • The USCI module expects the slave address to be passed in without the Read/Write bit, which it appends internally. It takes the rightmost seven bits of the address (unless 10-bit addressing is enabled), and sends those followed by the appropriate R/W bit value.

    Some datasheets give the address without the R/W bit, but others include it - particularly those that only support traffic in one direction. In this case I guess your clock generator only receives commands over I2C and doesn't allow the master to read anything back over the bus. Alternatively it might provide the address 0xD5 for use when the master wants to read from the slave.

    The solution is to pass the slave address as (0xD4 >> 1), ie 0x6A.

  • Hi Robert,

    what am i doing wrong with the MSP432 I2C?

    Becouse if i shift the Device Adress it Acknowledge, but if i dont it doesnt.

    So here you can see it works, but i send 9 Clocks and the Last one muss be ACK/NACK but is not! it is 0xD0 >> 1 == 0x6A

    Here you see the problem that i am facing, i am sending 0x72:

    The first Clock is Empty and the follow 8 Clocks are for the Data. But what i understood the last clock should be for ACK/NACK?

    Should i shift it to the right 0x72 << 1 ?

    Why do i have keep shifting the SDA Data?

    Is it a setting problem like MSB/LSB or Risging/Falling Edge? 

    Thanks in advance,

    Michael

  • I think you might be misreading the scope traces. The first image shows a "start" condition followed by the eight bit value 0xD0. That corresponds to a 7-bit slave address of 0x68 and a zero R/W bit to select write mode. After that the clock line stays low, presumably because the slave is clock‑stretching.

    The next image begins with the slave releasing the clock line while holding the data line low to acknowledge its address to the master. That's immediately followed by the eight data bits 0x72 from the master, and again the slave performs clock-stretching. The acknowledgement for the 0x72 and the stop or restart condition will have happened later (not shown on the trace).

    With I2C there are no options for MSB/LSB or rising/falling edge (or clock polarity) like there are for SPI. Also it's only the slave address that might require a 1-bit shift to convert between 8-bit addresses with the R/W bit already appended and 7-bit addresses without it. There's no need to shift data bytes before passing them to the eUSCI module.

  • This is interesting because I am having the very same problem that Michael describes.  I have a device at address 0xD4, but it doesn't give me a ACK unless I address 0x6A.   I think there is a problem with 10 bit addresses and Driverlib.  If I use a 7 bit address it reads correctly in my logic analyzer, but if I do a 10 bit address, it should give me a 0b1110 just after the start bit, to indicate this is a 10 bit address.    Michael, did you figure anything out?

    Thanks,

    Rob

  • Hi Rob,

    sorry no it didnt got it to work. I had to shiftet it too.
  • Thanks Michael, and too bad!  I guess I'll have to write a fix for driverlib.  The docs say it should work, but it doesn't send the right starting sequence for 10 bits, and when we shift things over, I think it works only because that makes our 10 bit address look like a 7 bit address, and we were lucky that our address was even, because I don't think it wouldn't have worked if it was odd.  Again, thanks for the answer.  If I get it going, I'll post back here with my solution.

    Thanks,

    Rob

  • One thing I just noted is that the May 2015 Driverlib Users Guide says it only works for 7 bit addresses, but the November 2015 edition says it works for 7 and 10 bit addresses. I think I have the latest MSPWare (3_20_00_37), because when I check for updates, there are note, but the docs seem to indicate that this might have been a change somewhere along the line last year.
  • Okay, so this is the answer. Some vendors specify eight bit addresses (NXP and IDT are two examples), when they really mean the address is seven bits. They add the R/_W bit to the end of the seven bit address. This makes a seven bit address into an eight bit address. It appears that they usually do it with the R/_W bit as 0. So specifying 0x6a is correct.

    There is another issue for TI here, and that is to use the 10 bit addressing mode with I2C_setSlaveAddress(), they specify that it works with a 10 bit or a 7 bit address. It should set UCSLA10 of the UCB1CTLW0 control register appropriately, but it does not. Maybe this should be done in the i2cConfig data structure used in I2C_initMaster(EUSCI_B1_BASE, &i2cConfig), where it should be set. I did verify that changing this bit does indeed change the protocol to ten bit mode if you do it just after the I2C_initMaster(EUSCI_B1_BASE, &i2cConfig); call.

    /* Initializing I2C Master to parameters in i2cConfig */
    I2C_initMaster(EUSCI_B1_BASE, &i2cConfig);
    UCB1CTLW0 |= UCSLA10;

    TI please fix this!

  • Hello Sir,

    I am using MSP432P401R launchpad and trying to communicate FRAM 24CL04 using I2C.

    Working on example code "i2c_master_rw_repeated_start-master_code.c", slave address of my device is 0xA0

    but by shifting it 0xA0>>1 i.e 0x50 does not work(shows SDA low & SCL high). And if I pass slave address 0xA0, it shows waveform of

    -> 1st start bit(high to low transition) then 0x40.

    Pls suggest solution for this problem.

  • Hi Supriya,
    looks like TI Driver shifts the slave address for you. Can you plot the digital logic when you set the address at 0xA0?
    Is the SDA still low or are both high after the communication?
  • Hello Sir,

    Please find below digital logic, if I set slave address - 0xA0.

    CH1 (Yellow) - -> SCl

    CH2 (Blue) - -> SDA

  • Slave address are 7bit long normally and the first bit is for READ/WRITE commands.
    So if your slave address is 0xA0 than you will have to shifted it so would be 0x50.
    The first SCL clock is the start bit followed from 7 slave address bits and after that the next clock is READ/WRITE and last clock is aknowledge.
    The Master hold the SDA low until the slave with that corresponded address pulls it back up. There is no slave with 0x80 on the bus so shift the addres 0xA0 to 0x50 and please add for us the plot for that here too.
  • Hello SIr,

    By setting slave address 0x50 instead of 0xA0, I am not getting any pulse on  SCL(remains high continuously) and SDA (remains low cont.).

    Using 4.7k pull ups in H/w  for SCL & SDA.

    Please help to solve this issue.

  • Hi Supriya,

    you have to power cycle your board so SDA and SCL are High again. 

    If they are not High at init, you may have a hardware problem or the 4k7 pull ups by SDA are not solded well.

    Make sure you put a break point where you are sending the slave address and debug it until there and see if SCL and SDA are still high.

    Then go over the i2c command and check if it accept the slave address or not. If not SDA will be put low.

  • Hi Sir,

    Now It is been observed that, I am getting pulses only at power on, further  SDA becomes low  and SCL becomes continuously high.

    See below plot getting only at power on(for few seconds).  why is this happening?

    CH1-SDA

    CH2-SCL

  • The slave address looks good now.
    What are you sending on i2C read or write? which register value you want to read/write?
    Can you screen shot channel 1 same level as channel 2 and only the first command.
  • I am transmitting multiBytes ->

    TXData[10] = {0x00, 0x3A, 0x1E, 0x39, 0x1C, 0x79, 0x5D, 0x6C, 0x0C, 0x01};

    in my code. But my aim is to Read/Write Float value at one location in external FRAM.

    I have still not understood why the waveform is visible only at power on for few seconds??

  • well this depens on your code.
    The I2C communication seems to work, the slave responds to its master.
    You could you simplify your code for first and write to the slave in the 0x00 register this value 0x3A.
    After that read the register 0x00 and see if you get 0x3A back.
    If you want to write 10 values from TXData[10] you will need to say which register should each value be writting in.
    Say you start at register 0x00 and you could just increment each register write commands at one.
    Resgiter 0x00 would have value TData[0]
    Resgiter 0x01 would have value TData[1]
    Resgiter 0x02 would have value TData[2]
    Resgiter 0x03 would have value TData[3]
    .....
    and so on.
    By reading the values you read the proper register entry.
  • Yes Sir, I came to know where i was making mistake in my code.
    Now I am getting waveform throughout.
    Till now my code was just transmitting data,Now I will try to read data from slave.
    Thank you So much for the support.
  • Hi Sypriya,

    you are welcome. Next time you have an issue, just open a new question on the forum so its better for others to track and reply.

    regards,

    michael
  • Hello Sir,
    I had created new thread for my issue - I2c Master reception issue. Will you please help me out.

**Attention** This is a public forum