KDS I2C master communication on nondefault pins

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KDS I2C master communication on nondefault pins

Jump to solution
681 Views
tomazlov
Contributor II

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 */
       PORT_HAL_SetMuxMode(PORTB,3u,kPortMuxAlt2);
       PORT_HAL_SetMuxMode(PORTB,4u,kPortMuxAlt2);
       break;
   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 */
       break;
   default:
       break;
   }
}
...
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
OSA_TimeDelay(1000);
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?

Labels (1)
1 Solution
511 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tomaz,

Please notice the PTA8 and PTA9 of FRDM-KL03Z is connect to THERMISTOR circuit by default.

PTA8 PTA9 FRDM-KL03Z.jpg

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

2 Replies
511 Views
tomazlov
Contributor II

Ok, now I see this...thank you for this clarification. Then I will just use default pins next to onboard accelerometer.

0 Kudos
512 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Tomaz,

Please notice the PTA8 and PTA9 of FRDM-KL03Z is connect to THERMISTOR circuit by default.

PTA8 PTA9 FRDM-KL03Z.jpg

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------