Other Parts Discussed in Thread: MMWAVE-SDK
Hi!
I'm trying to implement I2C slave functionality to the IWR6843 but the I2C slave driver does not transfer data. It detects start and stop condition, and I2CSlave_read() returns successfully when I write from a master to the IWR6843 slave with correct slave address, but no data is written to the buffer by I2CSlave_read(). Any ideas what could be wrong?
Here is my code simplified:
void Mmw_I2CInit (uint8_t taskPriority) { Task_Params taskParams; Task_Params_init(&taskParams); taskParams.priority = taskPriority; taskParams.stackSize = 4*1024; gI2CTaskHandle = Task_create(I2C_slave_task, &taskParams, NULL); return; } static void I2C_slave_task(UArg arg0, UArg arg1) { I2CSlave_Handle handle; I2CSlave_Params params; uint8_t i2c_com_buffer[2]; I2CSlave_init(); I2CSlave_Params_init(¶ms); params.transferMode = I2CSLAVE_MODE_BLOCKING; // This is the only mode available params.slaveAddress = 0x68; handle = I2CSlave_open(0, ¶ms); if (!handle) { System_printf("ERROR: I2C Slave did not open\n"); return; } while(1) { bool result = I2CSlave_read(handle, i2c_com_buffer, 2); if (!result) { System_printf("Unsuccessful I2CSlave read\n"); continue; } System_printf("Received bytes: %02x %02x\n",i2c_com_buffer[0],i2c_com_buffer[1]); } }
So my code prints "received bytes ..." to the console every time I write to the I2C slave but buffer only contains initialized 0xff data, not the data I wrote.
I also found that there has to be a delay (about 0.5 seconds ... 1 seconds) between writes, otherwise there will only be one "received bytes ..." message.
I debugged the driver by inserting breakpoints in the interrupt service routine and found that there are no interrupts other than start and stop conditions.
I also enabled DebugP Log and this is what is shown by Remote Object Viewer:
3 3206565 xdc.runtime.Main Debug: I2C Slave Driver(@08006d30) Registering HWI ISR for Interrupt 66 0 xdc.runtime.Log_print 52280 134245680 66 0 0 0 0 0 4 3207031 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) opened in BLOCKING Mode 0 xdc.runtime.Log_print 52348 -535552 0 0 0 0 0 0 5 3218627 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) Starting operation(Read) 0 xdc.runtime.Log_print 73192 -535552 73184 0 0 0 0 0 6 11850207783 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) ISR START DETECTED 0 xdc.runtime.Log_print 27912 -535552 0 0 0 0 0 0 7 11850210767 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) ISR STOP DETECTED 0 xdc.runtime.Log_print 28268 -535552 0 0 0 0 0 0 8 11850211063 xdc.runtime.Main Debug: I2C Slave Driver BLOCKING MODE - posting transfer complete semaphore. Status : 1 0 xdc.runtime.Log_print 110084 1 0 0 0 0 0 0 9 11850212060 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) Transfer OK 0 xdc.runtime.Log_print 73244 -535552 0 0 0 0 0 0 10 11850228067 xdc.runtime.Main Debug: I2C Slave Driver(@fff7d400) Starting operation(Read) 0 xdc.runtime.Log_print 73192 -535552 73184 0 0 0 0 0