AnsweredAssumed Answered

Switching to I2C0 module for FRDM-KL26Z

Question asked by Danyon Chu on May 25, 2017
Latest reply on May 30, 2017 by Visakhan C

I am using the driver example for I2C blocking, communicating using 2 FRDM-KL26Z boards (1 master, 1 slave). Currently the examples work, but on the board I am developing, I need I2C communication to happen over PTB2 and PTB3. When the hardware is initialized in the file 'hardware_init.c', you can call the function 'configure_i2c_pins' where you select I2C0 or I2C1 module. Looking into that function, if the arguments you pass in can either be 0U or 1U, where 1U corresponds to setting Port C pin1 and Port C pin 2 as your I2C pins. Sending in 0U should then set Port B pin2 and Port B pin 3 as your I2C pins. I also enabled the port clocks using the command 'CLOCK_SYS_EnablePortClock (PORTB_IDX);' .When changing the file on both the master and slave side to configure_i2c_pins(0U), I am not getting any communication through those pins. Am I misunderstanding the code?  Or is there additional places that I have to change the code to set those pins as I2C? If anyone could provide any insight on this, it would be much appreciated.

For reference, my hardware_init.c file now looks like this:

#include "board.h"

#include "pin_mux.h"

#include "fsl_clock_manager.h"

#include "fsl_debug_console.h"

 

void hardware_init(void) {

/* enable clock for PORTs */

CLOCK_SYS_EnablePortClock(PORTA_IDX);

CLOCK_SYS_EnablePortClock(PORTB_IDX);

CLOCK_SYS_EnablePortClock(PORTE_IDX);

configure_i2c_pins(0U);

/* Init board clock */

BOARD_ClockInit();

dbg_uart_init();

}

Outcomes