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?