AnsweredAssumed Answered

Kinetis KL25z I2C basic configuration

Question asked by Ulrich Steinlehner on Apr 22, 2016
Latest reply on May 4, 2016 by Kerry Zhou

Hi,

I'm trying to configure the I2C for the Kinetis Kl25z dev board (in codewarrior as bareboard project). I want to use the PTE0 and PTE1 pins for the I2C-Communication. The I2C should be configured for 50kHz.

My question, I configured the I2C Modul, like this:

_____________________________________________________________________________________________

#include <stdio.h>

#include "derivative.h" /* include peripheral declarations */

 

 

int main(void)

{

    int i=0;

        //I2C clock on

        SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK;

     

        //Port clocks on

        SIM_SCGC5 = SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK |          SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;

 

        //Set PIN as I2C1

        PORTE_PCR0 = PORT_PCR_MUX(6);

        PORTE_PCR1 = PORT_PCR_MUX(6);     

   

        //I2C Frequency Divider

        I2C1_F = 0x27;    //I2C to 50kHz

     

        I2C1_C1 = 0x50; //Enable I2C Modul

        I2C1_C1 |= I2C_C1_IICEN_MASK;

        for (i = 0; i < 100; i++);

        I2C1_C1 = 0x50;

    return 0;

}

 

_____________________________________________________________________________________________

 

If the I2C is configured right, there should be a clock signal with 50kHz?

What register is missing to activaite the I2C Clock, I have no Clock signal on SCL?

 

thank you

Outcomes