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.

OPT3001: Initialising I2C connection with MSP432 Launchpad not working , ends at "static void defaultISR(void)" function (Sensor BoosterPack)

Anonymous
Anonymous
Part Number: OPT3001
Other Parts Discussed in Thread: BOOSTXL-BASSENSORS

I am trying to read Lux values from the OPT3001 Sensor (on the Sensors BoosterPack) with my MSP432 Launchpad. I establish an I2C connection, but the task I created never executes. Using the debugger I find that after calling the function "sensorOpt3001Init()" the program jumps to this part.

/* This is the code that gets called when the processor receives an unexpected  */
/* interrupt.  This simply enters an infinite loop, preserving the system state */
/* for examination by a debugger.                                               */
static void defaultISR(void)
{
    /* Fault trap exempt from ULP advisor */
    #pragma diag_push
    #pragma CHECK_ULP("-2.1")

    /* Enter an infinite loop. */
    while(1)
    {
    }

    #pragma diag_pop
}

My code looks like this 

uint16_t RawOptValue = 0;
QueueHandle_t xOPTQueue;

 xOPTQueue = xQueueCreate(100, sizeof(float));

    initI2C();
    if(xOPTQueue != NULL)
    {
    xTaskCreate(read_OPT, "OPT Measurement", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
    }

    vTaskStartScheduler();



This is the task I create

void read_OPT(void* pvParameters)
{
    float ConvertedOptValue = 0.0;

    sensorOpt3001Init();

    for(;;){
        sensorOpt3001Enable(true);
        vTaskDelay(pdMS_TO_TICKS(1000));

        //Test if the sensor works, blink LED 100ms if it does

        if( sensorOpt3001Test() == true )
        {
            configTOGGLE_LED();
            vTaskDelay(pdMS_TO_TICKS(100));
            configTOGGLE_LED();
        }

        sensorOpt3001Read(&RawOptValue);
        sensorOpt3001Convert(RawOptValue, &ConvertedOptValue);

        sensorOpt3001Enable(false);


        // Send data to a queue

        if( xOPTQueue != NULL ){
        xQueueSend(xOPTQueue, (void *) &ConvertedOptValue, 0);
        }
    }
}


Does anyone have an idea why this happens? If I remove the function "initI2C()", I end up in

void I2C_masterSendMultiByteStart(uint32_t moduleInstance, uint8_t txData)
{
    //Store current transmit interrupt enable
    uint16_t txieStatus = EUSCI_B_CMSIS(moduleInstance)->rIE.r & UCTXIE;

    //Disable transmit interrupt enable
    BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rIE.r, UCTXIE_OFS) = 0;

    //Send start condition.
    EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r |= UCTR + UCTXSTT;

    //Poll for transmit interrupt flag.
    while (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rIFG.r, UCTXIFG_OFS))
        ;

    //Send single byte data.
    EUSCI_B_CMSIS(moduleInstance)->rTXBUF.r = txData;

    //Reinstate transmit interrupt enable
    EUSCI_B_CMSIS(moduleInstance)->rIE.r |= txieStatus;
}

and the program stops at the while statement. Is anyone familiar with this behaviour and can explain why this happens?

  • Dear Adem - 

    if you are using the SAIL plugin - i found a repair here (copied and pasted from the internal JIRA ticket I put in): 

    had to change ( in MSP_EXP432P401R.c, inside C:\Users\yourfilename\workspace_v9\i2copt3001_MSP_EXP432P401R_tirtos_ccs)

    /*

    • =============================== OPT3001 ===============================
      */
      #include <ti/sail/opt3001/opt3001.h>

    OPT3001_Object OPT3001_object[MSP_EXP432P401R_OPT3001COUNT];

    const OPT3001_HWAttrs OPT3001_hwAttrs[MSP_EXP432P401R_OPT3001COUNT] = {
    {
    #ifdef BOOSTXL_BASSENSORS
    .slaveAddress = OPT3001_SA1,
    #else // BOOSTXL_SENSORS
    .slaveAddress = OPT3001_SA*4*, // <==this is setting I2C address of the OPT to 1001110 (7 bit, which ends up being an 0x8E when the Write bit is applied) - i caught it doing this with an Logic Analyzer, which the part NACKed of course, changing this to a 1 makes it work, but i think the logic still needs attention, as i think the code example is intended to support both the BOOSTXL-SENSORS and the BOOSTXL-BASSENSORS boards. 

    #endif
    .gpioIndex = MSP_EXP432P401R_OPT3001_INT,
    },
    };

    const OPT3001_Config OPT3001_config[] = {

    { .hwAttrs = &OPT3001_hwAttrs[0], .object = &OPT3001_object[0], }

    ,
    {NULL, NULL}
    };

    /*

  • Anonymous
    0 Anonymous in reply to Josh Wyatt

    Thank you for the help but I am not using the SAIL Plugin.

  • Adem - 

    OK - well then you might want to use it as an example to get you going in the right direction. (with that one change i mentioned)