AnsweredAssumed Answered

KDS I2C master communication on nondefault pins

Question asked by Tomaz Lovrencic on Jan 4, 2018
Latest reply on Jan 5, 2018 by Tomaz Lovrencic

I am using dev board "FRDM-KL03Z" and now I am trying to modify I2C_blocking_master example (I am using KDS 3.2.0 project and Kinetis SDK v.1.3.0) so it would work with external I2C device (namely accelerometer LIS2DH12) on PORTA8 and PORTA9 pins.

As per board user manual and MCU datasheet I have made these changes:

- in file "hardware_init.c" I changed configure_i2c_pins(0) to configure_i2c_pins(I2C_EXT_LIS2DH) and I had defined new constant and pin muxes (in file "pin_mux.c") like this:

void configure_i2c_pins(uint32_t instance)
   switch(instance) {
   case I2C0_IDX: /* original I2C0 configuration for the board */
   case I2C_EXT_LIS2DH: /* my modified I2C0 on PORTA8 and PORTA9 */
       PORT_HAL_SetMuxMode(PORTA,8u,kPortMuxAlt2); /* PORTB_PCR8 */
       PORT_HAL_SetMuxMode(PORTA,9u,kPortMuxAlt2); /* PORTB_PCR9 */
Initialization goes OK:

// Initialize i2c master
i2c_status_t result = I2C_DRV_MasterInit(BOARD_I2C_INSTANCE, &master); // result = 0

but nothing is send on PORTA8 and PORTA9! If I check with debugger, the program first returns status 8, then 3 (obviously reporting an error):


i2c_status_t result = I2C_DRV_MasterSendDataBlocking(
        BOARD_I2C_INSTANCE,       // instance
        &slave,                   // i2c device
        (const uint8_t*)&cmdBuff, // cmdBuffer
        1,                        // cmdSize
        (const uint8_t*)cmdBuff,  // txBuff
        1,                        // txSize
        500);                     // timeout_ms
PRINTF("status send: %d\r\n", (int)result); // HERE I GET 8 (=I2C Arbitration Lost error) IN FIRST LOOP AFTER RESET,
                                              // THEN IT REPORTS RETURNING CODE 3 (=The master is already performing a transfer)


How can I initialize I2C on PORTA8 and PORTA9 and use function prototypes from SDK?