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.

EVM430-FR6047: I2C clock synchronization

Part Number: EVM430-FR6047
Other Parts Discussed in Thread: CC1310, MSP430FR6047

Hi support

I have an issue with my I2C communication btw. a CC1310 which i'm programming and the MSP430FR6047 water flow meter. On the most general plane i'm trying to do much of what the GUI does. Just from another microcontroller - the CC1310. I read the I2C packages btw the two MCU's with an analog discovery. When connected to the Waterdemo GUI it works as designed, but when I use the CC1310 I have some clock sync issues which might be the reason why I can't get it to work.

Here is a screenshot of the entire update param - command 0x96 - with the GUI->MSP on the top and mine in the bottom.

I use TI's API's to initialize the I2C and set frequence to 400 kHz - otherwise standard parameters. I can communicate, so the settings should be good. I just can't communicate as well as i hoped.

As you can clearly see. The clock is kept low at the beginning of each byte. If I zoom in the h09 part one can see that the timing is a bit different btw the data and clock

First focus was the I2C line itself. I have measured the pull up resistors and they are good. There is a slight difference in the clock frequency 

Not much, if even there is a difference if I had used the same scale.

I have a for loop which handles the I2C communication and mimics the GUI->MSP I2C communication. I send the comm96, waits for an interrupt in the Comm_IRQ line and then receives the read msg. After that I transmit the parameter and repeat that for all parameters.

The loop uses a function that takes a struct as an argument that contains the data to write or where the receive a read pkg. In that function the i2ctransaction struct is set and the I2CTransfer call is made.

Debugging the MSP430 shows me that I only set 3 parameters and the updatevalid flag is not set.

I can introduce a 3 sec. delay (not much faster than that) and then I can set all parameters BUT the valid flag remains false.

How do you manage that on the "GUI" side of your EVAL board?

Regards Lasse

  • Hi Lasse,

    Can you explain a bit about the code running on the CC1310:

    1) What SimpleLink CC13x0 SDK are you using?

    2) What example project is you application based on?

    3) What tasks are defined on the device and what tasks are running simultaneously with the I2C?

  • Thank you for your reply Marie.

    In reply to your questions this is what I have:

    0) I think I forgot to mention that I have checked the voltage at SDA and SCL which are good, so the pull-up resistors are okay.

    1) Simplelink SDK: simplelink_cc13x0_sdk_3_20_00_23

    2) The project is originally based on the i2ctmp project (but not much remain from that apart from the I2C_init part)

    3) I have 1 task running - mainThread - which calls my setparameters() function.

    So it should be the only task running. At the time of writing the original post setparameters() was called in a while(1) loop

    while(1)
    {
    setparameters();
    sleep(1); //had a breakpoint here and then checked the MSP for the parameters
    }

    As you can see in the first post this function then calls a I2CCommunications function which does this:

    bool I2CCommunication(struct I2CtransactionStruct *CommStruct)
    {
    
    i2c = I2C_open(Board_I2C0, &i2cParams);
    
        if (CommStruct->write) 
    {
            i2cTransaction.writeBuf = Write_buffer;
            i2cTransaction.writeCount = CommStruct->length;
            i2cTransaction.readBuf = 0;
            i2cTransaction.readCount = 0;
        } else (!CommStruct->write) {
            i2cTransaction.writeBuf = 0;
            i2cTransaction.writeCount = 0;
            i2cTransaction.readBuf = Read_buffer;
            i2cTransaction.readCount = CommStruct->length;
        }
    
    //Prepare write message if CommStruct->write
    
      //loop to handle each transmitted or received package
        while (CommStruct->count-- > 0) {
    
            if (CommStruct->wait) {
                //sem_res_bool = Semaphore_pend(captureSem, (7000 * (1000 / Clock_tickPeriod)));
    
                while (GPIO_read(Board_DIO1) == 1) {
                    //Do nothing
                }
                interrupt_counter++;
                //sem_res = sem_timedwait(&captureSem, &ts);
    
            }
    
            if ((res = I2C_transfer(i2c, Transaction) == true)) {
            } else {
                I2C_close(i2c);
                return false;
            }
    
    //unpack package if it was a received package
    }


    I have highlighted some code which solved some of the issues.

    I have commented the semaphore part out (tried both your API and POSIX). This part waits for the COMM_IRQ line interrupt when I expect a read package.
    Without the semaphore but just a simple while loop it actually works as planned.

    However, the clock synchronization part remains (sorry about the IRQ line just being capped).



    So to sum up.
    1) I can set the parameters without the semaphores (will have to try again with that part later)
    2) The update valid flag is now set
    3) It works even though I have the clock synchronization problem

    TI's I2C troubleshooting guide (I think it was there) mentioned that even though clk sync is part of the I2C protocol, its preferable to avoid it. So the question remains why its there?
    But perhaps its not that easy a question to answer.

  • Hi Lasse, 

    Could you please elaborate more on your CC1310 code? To be more precise, could you include I2C params used as well as the definition of "I2CtransactionStruct" as well as what "Transaction" in I2C_transfer(i2c, Transaction) is.

    I would assume "Transaction" to read "i2cTransaction". I'm not sure I understand your architecture with the "commStruct" and how it works in the bigger picture. To give any good feedback to why it seems like you are stretching the clock I would need to know all details about your custom build up. If you do not want to share it here, feel free to reach out to me in PM.

**Attention** This is a public forum