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.

  • Resolved

cc3200 can't setup i2c communication

Intellectual 980 points

Replies: 22

Views: 5962

Hi,

I'm trying to setup i2c, but with no success. I'll be grateful if somebody can point me to what I'm doing wrong.

Here is my code:

PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

// Configure PIN_01 for I2C0 I2C_SCL
PinTypeI2C(PIN_01, PIN_MODE_1);

// Configure PIN_02 for I2C0 I2C_SDA
PinTypeI2C(PIN_02, PIN_MODE_1);



MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
MAP_PRCMPeripheralReset(PRCM_I2CA0);

MAP_I2CMasterInitExpClk (PRCM_I2CA0, 80000000, false);


// send 0x01 byte - this part works fine on a tiva launchpad, but not here
I2CMasterSlaveAddrSet(PRCM_I2CA0, 0x42 >> 1, false);
I2CMasterDataPut (PRCM_I2CA0, 0x01);
I2CMasterControl (PRCM_I2CA0, I2C_MASTER_CMD_SINGLE_SEND);

while(I2CMasterBusy(PRCM_I2CA0));  // <-- it hangs here

So it always hangs in the while loop and looking with the LA - no data is sent - both lines remain dead.

My wirings are SCL -> p01, SDA -> p02

Both lines have pull up resistors and I've removed the J2, J3, J4 jumpers.

Any idea what I may be doing wrong?

Thanks in advance!

  • I managed to get i2c communication, but using the i2c_demo program and using the p01, p02 pins.

    I put back the j2, j3 jumpers - looks like this way no pull ups are needed.

    So I get communication now, but problem is I2C works only on p01 and p02.

    If I change the pinmux to this (taken from the camera demo):

    // Configure PIN_16 for I2C0 I2C_SCL
    PinTypeI2C(PIN_16, PIN_MODE_9);
    
    // Configure PIN_17 for I2C0 I2C_SDA
    PinTypeI2C(PIN_17, PIN_MODE_9);

    i2c still keeps working on p01 and p02... And doesn't work on 16 and 17.

    I had a similar problem with UART (http://e2e.ti.com/support/wireless_connectivity/f/968/p/370679/1303668.aspx#1303668) and problem there was that the breakout board routes only certain pins to the uart and not all that are shown in the pinmux tool. So they had to be routed manually... 

    Is it the same here? Is this how the camera booster pack manages to use the 16 and 17 pins - by some additional routing? How can I figure out what needs to be routed where?

  • In reply to Lacho Tomov:

    Hi Lacho,

    Thats right! On the launchpad, only certain lines are routed from the chip to the on-board sensors to work using I2C. Similarly, to work with the camera BP, pin 16 and 17 are used and the I2C lines on the Camera BP are connected accordingly.

    Best regards,

    Naveen

     

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Naveen Narayanan:

    Thanks Naveen, yet I can't figure out what connections I need to make in order to make an external i2c device work on pins 16 and 17.

    I understand that in order to read the onboard sensors - only p01 and p02 can be used - 16 and 17 are simply not connected to these sensors.

    But I don't see what's the problem with reading an external i2c device using pins 16 and 17. 

    Looking at the launchpad schematic it seems like the 16 and 17 pins from the cc3200 chip are connected to the same launchpad pins (if I'm reading it right)... So my understanding is that I only need to put some pull-up resistors, do the pinmux and perhaps disconnect j2 and j3 (or maybe not)... but nope - doesn't work :)

    Is there by any chance a schematic already available for the camera booster pack? :) It will be helpful to see how exactly the wiring goes there.

  • In reply to Lacho Tomov:

    Hi Lacho,

    That should have worked.

    Alternately, you could connect J2 and J3 and use p01 and p02 that are also available at the header (P1.9 and P1.10) and connect them to the external i2c device. So you would have one more i2c device on the bus and could use the i2c_demo example to test your device.

    Best regards,

    Naveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Naveen Narayanan:

    Naveen Narayanan
    That should have worked.

    That's good to know, so my problem is somewhere else. I'll keep digging to see if I can find it.

    The thing is that pins 01 and 02 are used by the camera interface, so I need to use something else.

    Thanks for the tips!

  • In reply to Lacho Tomov:

    Hi Lacho,

    I hope you are also configuring the SOP pins to be working in SWD mode for debug.

    Quoting from the CC32xx Camera Application.pdf

    Configuring the target device

    1. Ensure SOP 0 is mounted on the CC3200 launchpad. Make sure to remove the same and mount SOP 2 while

    flashing the binary application. Since, TDI and TDO are used for I2C interface, the JTAG is operational in SWD

    mode.

    2. Since SWD mode is used, make sure to un-mount J10 and J11 jumpers so that TDI and TDO lines are not being

    used.

    Best regards,

    Naveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Naveen Narayanan:

    Hi Naveen,

    Unfortunately when I set the jumpers like that I can no longer upload the code with CCS. I tried all kinds of combinations SOP0, SOP2, resetting, replugging the board before upload... whenever I remove the j10 and j11 jumpers - upload stops working.

    But indeed this should be my problem - pins 16 and 17 are used for JTAG, which explains why i2c doesn't work for them.

    I'll play with this a bit more to see if I can get it to work.

  • In reply to Lacho Tomov:

    Hi Lacho,

    Please refer to section on "Executing a Project" in the CC3200-Programmers_Guide document to configure CCS to work in SWD mode. This could resolve the issue you are facing with CCS.

    Best regards,

    Naveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Naveen Narayanan:

    Hi Naveen,

    I'm trying out the camera application on CC3200. I do not have the camera BP in hand, so I connect the MT9D111 module to the lunch pad directly. I found that the I2C just issue the start signal and then stay in the while loop polling the byte transmitted flag. I have added the pull up resisters on P16 and P17, removed J10and J11, connected J6 and J7 to BP, removed J2 and J3, mounted SOP0, removed SOP2. Have I missed something? 

    I also tried the i2c_demo application. when I2C is mapped to P01 and P02, it works well, but when mapped to P16 and P17, it didn't work. When mapped to P16 and P17, I also removed J10 and J11, mounted SOP0 and added pull up resisters.

    Is there anything special when using P16 and P17 as I2C?

    Thanks in advance.

    Best regards,

    Guohui

  • In reply to guohui Xu:

    Hi Guohui,

    Can you use the I2CMasterLineStateGet() API to to read out the status of the I2C lines before issuing any  I2C command. This should return 0x3, meaning both SDA and SCL lines are pulled up.

    What is the value of the pull up resistors you are using ?

    Thanks and Regards,

    Praveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

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.