Hi,
I tryed to Write a driver in C++, to command a EEPROM connected to I2C1 port on my K22 microcontroller.
I have a problema when a tried to write a command using I2C_MasterTransferBlocking, I'm not able to write register D (DATA) of I2C1 port, The function I2C_MasterTransferBlocking, calls I2C_MasterStart.
When I debug I2C_MasterStart , after the following line:
base->D = (((uint32_t)address) << 1U | ((direction == kI2C_Read) ? 1U : 0U));
the register base->D is allways 0, even if the address is not 0.
I cannot understand Why?
I folowed this example:
...
...
sourceClock = I2C_MASTER_CLK_FREQ;
I2C_MasterInit(EXAMPLE_I2C_MASTER_BASEADDR, &masterConfig, sourceClock);
memset(&masterXfer, 0, sizeof(masterXfer));
/* subAddress = 0x01, data = g_master_txBuff - write to slave.
start + slaveaddress(w) + subAddress + length of data buffer + data buffer + stop*/
uint8_t deviceAddress = 0x01U;
masterXfer.slaveAddress = I2C_MASTER_SLAVE_ADDR_7BIT;
masterXfer.direction = kI2C_Write;
masterXfer.subaddress = (uint32_t)deviceAddress;
masterXfer.subaddressSize = 1;
masterXfer.data = g_master_txBuff;
masterXfer.dataSize = I2C_DATA_LENGTH;
masterXfer.flags = kI2C_TransferDefaultFlag;
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer);
PRINTF("Receive sent data from slave :");
..