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/CC2640: I2c with Interrupt

Part Number: CC2640
Other Parts Discussed in Thread: CC2650

Tool/software: Code Composer Studio

Hi,

I am using interrupt and I2C function (for Accelerometer) together.

Interrupt is working fine, but when I enable I2c function it stops working. I am wondering whats wrong with it. 

I am writing some part of code for understanding

/// ************************* I2C Code  ************************* ///

 #define Board_SDA IOID_9 

#define Board_SCL IOID_10

 

static PIN_Config SBP_configTable[] ={ 

 Button_Input | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
 Board_SDA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,

Board_SCL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,

PIN_TERMINATE
};

static I2C_Handle SbpI2cHandle;
static I2C_Params SbpI2cParams;

I2C_Params_init(&SbpI2cParams);

SbpI2cHandle = I2C_open(CC2650_I2C0, &SbpI2cParams);
if(!SbpI2cHandle){
  //code will come here if i2c is pins are not opened
}

/// ************************* Interrupt Code  ************************* ///

#define Button_Input IOID_14

static void buttonHwiFxn(PIN_Handle hPin, PIN_Id pinId){
  // set event in SBP task to process outside of hwi context
  events |= SBP_BTN_EVT;

  // Wake up the application.
  Semaphore_post(sem);
}

PIN_registerIntCb(hSbpPins, buttonHwiFxn);

// Configure interrupt
PIN_setConfig(hSbpPins, PIN_BM_IRQ, Button_Input | PIN_IRQ_POSEDGE);


// Enable wakeup
PIN_setConfig(hSbpPins, PINCC26XX_BM_WAKEUP, Button_Input |PINCC26XX_WAKEUP_POSEDGE);

if (events & SBP_BTN_EVT){

  events &= ~SBP_BTN_EVT; //clear event

 //Blink LED
}

  • Hi Sumair,

    If you put a breakpoint on your interrupt callback does it no longer get called after you add the I2C?

    BR,
    Gerardo
  • There is a conflict in hspPins and I2C_init function

    When I use sequence 1, interrupt works and SPI pins dont intialized and when i use sequence 2 SPI function works but interrupt pin doesnt initialized.

    Sequence 1
    hSbpPins = PIN_open(&sbpPins, SBP_configTable); //open pins after opening all drivers like i2c uart etc


    if(!hSbpPins)
    {
       //code will come here if button and pins are not opened
    }

    I2C_Params_init(&SbpI2cParams);

    SbpI2cHandle = I2C_open(CC2650_I2C0, &SbpI2cParams);
    if(!SbpI2cHandle)
    {
      //code will come here if i2c is pins are not opened
    }

    -----------------xxx--------------------

    Sequence 2

    if(!hSbpPins)
    {
       //code will come here if button and pins are not opened
    }

    I2C_Params_init(&SbpI2cParams);

    SbpI2cHandle = I2C_open(CC2650_I2C0, &SbpI2cParams);
    if(!SbpI2cHandle)
    {
      //code will come here if i2c is pins are not opened

    -----------------xxx--------------------

     

    static PIN_Config SBP_configTable[] =
    {

    Button_Input | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,

    Board_SDA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,

    Board_SCL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
    };

  • Hi Sumair,

    The problem seems to be that you have your I2C pins on your SBP_configTable and are calling PIN_open() on these, and therefore this are getting allocated to your application and the driver can no longer acquire them. You need to remove the I2C pins from your SBP_configTable as these will be handled by the driver itself.

    Thanks,
    Gerardo
  • Hello Gerardo,

    After posting this I realized the same thing and I removed the I2C pins fro SBP_configTable and it works.

    Thanks for your help