Part Number: MSPM33C321A
Hi team,
I'm working with the LP-MSPM33C321A and was able to make the timer work but have a problem of sending data to an I2C sensor. The following code should send one byte register address and one byte data to the sensor, but it is always stuck waiting at the Tx Buffer Empty: DL_I2CC_isTXFIFOEmpty(I2C_INST);
What may be causing this to stick here? Do I need to configure the FIFO size/threshold before use? I am using the example which has 64-byte FIFO size (maybe too big for 2-byte data transfer?)
The I2C bus is pulled to 3.3 Volts with 10K resister and I can measure the voltage is correct on the bus.
void Sensor_write_reg(uint8_t reg, uint8_t data)
{
transmitData[0] = reg; // Reg address
transmitData[1] = data; // Data to the Reg
/*
* Fill FIFO with data.
*/
Size = DL_I2CC_fillTXFIFO(I2C_INST, &transmitData[0], CommandSize);
// Start transfer
DL_I2CC_startTransfer(I2C_INST,I2C_TARGET_ADDRESS,DL_I2CC_DIRECTION_TX, CommandSize);
// Wait for TX FIFO ready but the code waits here forever..........
while (DL_I2CC_isTXFIFOEmpty(I2C_INST) == 0 && DL_I2CC_getStatus(I2C_INST) != DL_I2CC_STATUS_ERROR) {
};
/* Wait for I2C to be Idle */
while (!(DL_I2CC_getStatus(I2C_INST) & DL_I2CC_STATUS_IDLE))
;
/* Add delay between transfers */
delay_cycles(1000);
}
Best,
Luke