Hello, I was hoping someone could help me with an issue with the LPI2C Driver in the S32K148 SDK. I'm using an I2C multiplexer in order to interface with several devices with the same address, but the multiplexer needs an I2C STOP packet before it will actually activate and switch devices.
The issue here is if I try to send I2C packets too quickly, the driver appears to convert my STOP packets into START_REPEAT packets, which the multiplexer will not respond to.
I suspect this may have something to do with the hardware FIFO trying to optimize / consolidate packets. Is there a way I could disable this behavior? Or failing that, detect when the bus is fully stopped?
Minimal example code:
while (true) {
size_t buffer_size = 1;
// Select each I2C Mux output in sequence
for (int i = 0; i < 4; i+=1) {
masterTxBuffer[0] = 1 << i;
LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, masterTxBuffer, buffer_size, true, 1000);
}
for (volatile int i = 0; i < 2000; i++ ) {} // wait a bit
// Select each I2C Mux output in sequence, with a delay
// This works
for (int i = 0; i < 4; i+=1) {
masterTxBuffer[0] = 1 << i;
LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, masterTxBuffer, buffer_size, true, 1000);
for (volatile int i = 0; i < 1000; i++ ) {} // wait a bit so a stop is sent
}
// wait a bit
for (int i = 0; i < 100000; i++ ) {}
}
I've attached the view from my digital logic analyzer -- as you can see adding the short busy wait allows the Mux to take affect.
Thanks.