Part Number: MSP432P401R Tool/software: TI-RTOS We are conducting various failure tests for a project using TI-RTOS /MSP432, and one test involves device operation with an I2C bus that has no pull-ups/devices connected. The ideal solution involves the I2C transfer failing, but control returning to the application. We have observed that there is no I2C timeout functionality, therefore we have implemented our own per . Unfortunately, the Semaphore_pend does not appear to timeout. When pausing the code in the debugger we find it hanging at line 16 of the below function (in i2c.c). bool I2C_masterSendMultiByteFinish(uint32_t moduleInstance, uint8_t txData) { //If interrupts are not used, poll for flags if (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->IE, EUSCI_B_IE_TXIE0_OFS)) { //Poll for transmit interrupt flag. while (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->IFG, EUSCI_B_IFG_TXIFG0_OFS)) ; } //Send single byte data. EUSCI_B_CMSIS(moduleInstance)->TXBUF = txData; //Poll for transmit interrupt flag. while (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->IFG, EUSCI_B_IFG_TXIFG0_OFS) && !BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->IFG, EUSCI_B_IFG_NACKIFG_OFS)) ; if(BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->IFG, EUSCI_B_IFG_NACKIFG_OFS)) return false; //Send stop condition. BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->CTLW0, EUSCI_B_CTLW0_TXSTP_OFS) = 1; return true; } The highlighted line is the semaphore used to protect the I2C transfer and to (ideally) enact the timeout. We are finding that no breakpoints after/at the Semaphore_pend timeout are being reached, and randomly pausing the debugger shows it to always be at line 16 as above. Our I2C wrapper has the following code to implement the timeout. // Wait for callback to post the status of the I2C or timeout if (Semaphore_pend(sem_i2cTimeout, 100) == 0) { // Transfer failed I2C_cancel(handle); return false; } We set the Call back function to be: void I2c::ManageI2cTimeout(I2C_Handle handle, I2C_Transaction* i2c_transaction, bool success) { if (i2c_transaction->arg != NULL) { Semaphore_post((Semaphore_Handle)(i2c_transaction->arg)); } } However a breakpoint in this function is also not reached. Do you have any recommendations or advice as to how we can successfully implement an I2C timeout that works when no bus or pull-ups are connected? Thank you in advance, Anthony
↧