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

CC2650EM-7ID-RD: CC2650 SW I2C configure issue

Prodigy 200 points

Replies: 1

Views: 280

Part Number: CC2650EM-7ID-RD

Hello.

I'm trying to implement SW I2C function via GPIOs.

Actually I can control IOs as I expected but have problem when I read IO.

1) I2C CLK output is working well

2) I2C SDA output is working well

3) when I configure SDA pin to input, need to read data from slave via SDA, I couldn't get correct data...usually it reads zero even though there is coming data

4) GPIO configuration is like as below

  (1) PIN_init()  : configures IOs

  (2) PIN_open()  : open pins which are initialized at PIN_init()

  (3) output SCK and SDA

  (4) configure SDA port to input via "PIN_setConfig(sw_i2cPinHandle, PIN_BM_INPUT_EN, SW_I2C2_SDA_Pin);"

  (5) and read pin like as "val = PIN_getInputValue( SW_I2C2_SDA_Pin);"

  (6) and configure to output again, PIN_setConfig(sw_i2cPinHandle, PIN_BM_GPIO_OUTPUT_EN, SW_I2C2_SDA_Pin);

5) I couldn't read data correctly from this procedure and after this, I couldn't control SDA output even I can control SCK

6) I'm not sure whether I can control GPIOs in/out successively

Could someone let me know how I can handle this?

Many thanks.

BR.

Louiey

  • Hi,

    • Your call to PIN_setConfig() looks wrong. You can find the API documentation for PIN_setConfig() online. Especially pay attention to the configuration mask. There is a good overview table in the linked document. Input and output functionality are configured with distinct flags and the input functionality needs to be disabled explicitly.
    • Always check that the return code of those driver functions is PIN_SUCCESS, at least during development.
    // Switch from input to output. 
    // This does not touch buffer, drive strength, IRQ configuration.
    PIN_Config configMask = PIN_BM_INPUT_MODE | PIN_BM_GPIO_OUTPUT_EN;
    PIN_Config newConfig = SW_I2C2_SDA_Pin | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_EN;
    PIN_Status result = PIN_setConfig(sw_i2cPinHandle, configMask, newConfig);
    assert(result == PIN_SUCCESS);

    Best regards

    Richard

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.