Hey there,
I am struggling with setting up the i2c interface on my MK10DX128VLH7 microprocessor.
Currently I am using KDS to code, but I'm not using Processor Expert.
Could anybody provide an example on how to setup and send 3 data bytes? The MCU should be the master. I want to send 3 bytes (address+data+data). I thought that shouldn't be that difficult...
I basically did the following:
SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK; //Turn on clock to I2C1 module
/* configure GPIO for I2C1 function*/
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;
PORTE_PCR0 = PORT_PCR_MUX(0x06);
PORTE_PCR1 = PORT_PCR_MUX(0x06);
/* set MULT and ICR -> S.1141 */
I2C1_F = 0x14;
//I2C1_C1 = I2C_C1_IICEN_MASK; /* enable IIC */
I2C1_C1 = 0x80u; /* s1142 enable IIC - Feld 7 */
/* send start signal */
I2C1_C1 |= 0x10;
I2C1_C1 |= I2C_C1_MST_MASK;
/* send ID with W/R bit */
i2c_write(SlaveID);
//wait
while((I2C1_S & I2C_S_IICIF_MASK)==0) {};
I2C1_S |= I2C_S_IICIF_MASK;
// send data byte
I2C1_D = data;
// send stop
I2C1_C1 &= ~I2C_C1_MST_MASK;
I2C1_C1 &= ~I2C_C1_TX_MASK;
With this code, I hoped to transmit one byte, am I missing something?