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.

CCS/CC1352P: I2C_transfer() hangs while master device is operating in callback mode

Part Number: CC1352P
Other Parts Discussed in Thread: ADS7924

Tool/software: Code Composer Studio

So I am working on a custom board using the CC1352P to talk to a ADS7924 ADC over I2C. I am currently using the latest version of the CC13x2_ 26x2 3.40.0.2 SDK. The custom board does include the pull up resistors and the master (1352) is set up in callback mode.

The issue is that the I2C_open(...) returns successfully and initializes, however, when I go to make the transaction, the entire program hangs up and does not make a transfer. The code also never reaches the callback function.I am going to try and include all relevant code here.

FWI.. the main thread is being created and BIOS_start() is being called in the main_tirtos.c file. This code stemmed from the driver example called 'empty' in the SDK.

**********************************************************************

#include <ti/drivers/I2C.h>
 #include <semaphore.h>

#define ADS792_SLV_ADDR 0x49

sem_t i2cSem;

I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;

void setup_I2C(void) {
    I2C_init();
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    i2cParams.transferMode  = I2C_MODE_CALLBACK;
    i2cParams.transferCallbackFxn = i2cTransferCompleteFxn;
    i2c = I2C_open(CONFIG_I2C_0, &i2cParams);
    if (i2c != NULL) {
        Display_printf(display, 0, 0, "Success in Initializing I2C");
    }
}

void adcConfigRegWrite(uint8_t reg, uint8_t data) {
   uint8_t txBuffer[2] = {reg, data};
   i2cTransaction.slaveAddress = ADS792_SLV_ADDR;
   i2cTransaction.writeBuf = (void *)txBuffer;
   i2cTransaction.writeCount = 2;
   i2cTransaction.readBuf = NULL;
   i2cTransaction.readCount = 0;
   bool transferOK;

   transferOK = I2C_transfer(i2c, &i2cTransaction);
   if (transferOK) {
       sem_wait(&i2cSem);
       Display_printf(display, 0, 0, "I2C Transfer was successful");
   } else {
       Display_printf(display, 0, 0, "josh");
   }
}

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    /* Call driver init functions */
    GPIO_init();


    uint32_t status = sem_init(&i2cSem, 0, 0);
    if(status == 0) {
        Display_printf(display, 0, 0, "Created i2cSem");
    }

    setup_I2C();
    adcConfigRegWrite(20, 0x60);

    return 0;
}

**********************************************************************

/*
* =============================== I2C ===============================
*/

#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CCC26XX.h>
#include <ti/drivers/power/PowerCC26XX.h>

#define CONFIG_I2C_COUNT 1

/*
* ======== i2cCC26xxObjects ========
*/
I2CCC26XX_Object i2cCC26xxObjects[CONFIG_I2C_COUNT];

/*
* ======== i2cCC26xxHWAttrs ========
*/
const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CONFIG_I2C_COUNT] = {
/* CONFIG_I2C_0 */
{
.baseAddr = I2C0_BASE,
.powerMngrId = PowerCC26XX_PERIPH_I2C0,
.intNum = INT_I2C_IRQ,
.intPriority = (~0),
.swiPriority = 0,
.sclPin = IOID_21,
.sdaPin = IOID_5
},
};

/*
* ======== I2C_config ========
*/
const I2C_Config I2C_config[CONFIG_I2C_COUNT] = {
/* CONFIG_I2C_0 */
{
.fxnTablePtr = &I2CCC26XX_fxnTable,
.object = &i2cCC26xxObjects[CONFIG_I2C_0],
.hwAttrs = &i2cCC26xxHWAttrs[CONFIG_I2C_0]
},
};

const uint_least8_t I2C_count = CONFIG_I2C_COUNT;

const PIN_Config BoardGpioInitTable[] = {
CONFIG_PIN_6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
/* Parent Signal: CONFIG_I2C_0 SDA, (DIO5) */
CONFIG_PIN_8 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
/* Parent Signal: CONFIG_I2C_0 SCL, (DIO21) */
CONFIG_PIN_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
PIN_TERMINATE
};

  • Hi Josh,

    1) What example project have you based your application on?

    2) When this happens, does the whole program hang or is it just the I2C doesn't respond?

    3) Can you start a debug session and hit pause when this happens, then post a screen shot of the call stack?