Can't use I2C_1 on Kinetis K70

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Can't use I2C_1 on Kinetis K70

1,773件の閲覧回数
andy87
Contributor II

Hey,

Why i cant use the I2C_1-Interface on the Kinetis K70-Board.

I use the I2C_0-Interface and it works.

I see no reason for this on the schematic.

Best regards,

Andy


ラベル(2)
0 件の賞賛
返信
6 返答(返信)

1,350件の閲覧回数
peter_fenn
Contributor V

Andy


If referring to the TWR-K70F120M Tower Module:
- where specifically are you measuring those PTE0 and PTE1 signals? - on the J7A-B22 and J7A-B11 Tower connector pins?

- do you perhaps have a microSD card inserted in J15 that could be interfering?

Peter

0 件の賞賛
返信

1,350件の閲覧回数
andy87
Contributor II

Hey Peter,

Jep, i measured it on the Tower on B22 and B11.

Unfortunately i have no SD-Card in J15 inserted.

By the way if i wanna use PTF2 and PTF3 for the I2C1-Interface, nothing happens here too.

Could it be that my Oszillator for the I2C1-Interface is damaged?

0 件の賞賛
返信

1,350件の閲覧回数
JimDon
Senior Contributor III

Did you set the pin control register properly? Why do you say you can't?

0 件の賞賛
返信

1,350件の閲覧回数
andy87
Contributor II

Nothing happens on the SDA and SCL-Lines.

They are always LOW.

I post the Code:

void i2c_master_init(void)

{   

    SIM_SCGC4 |= 0xC0; //Turn on clock to I2C0 and I2C1 module

  

    PORTE_PCR0 = PORT_PCR_MUX(6);   // SDA

    PORTE_PCR1 = PORT_PCR_MUX(6);   //SCL

  // I2C1 clock configuration

     I2C1_F = 0x23;                            // I2C bus clock 100 kHz

}

char i2c_get_data(unsigned char register_address, unsigned char SlaveID){

    char data=0;

    unsigned char slaveID_read =0;

    unsigned char slaveID_write=0;

   

      /* shift ID in right possition */

      slaveID_write = (unsigned char) SlaveID << 1;

      slaveID_read = (unsigned char) SlaveID << 1;

    

      /* Set R/W bit at end of Slave Address */

      slaveID_write |= (unsigned char)MWSR;

      slaveID_read |= (unsigned char)MRSW;

     

    // read out register   

        I2C1_C1 |= I2C_C1_IICEN_MASK;                // enable I2C1

        I2C1_C1 |= I2C_C1_MST_MASK;                   // I2C1 is master, start condition

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

        I2C1_C1 |= I2C_C1_TX_MASK;                    // transmit mode 

        I2C1_D = slaveID_write;                        // write address

        transfer_complete();                        // wait until transfer is complete

       

        I2C1_D = register_address;                    // address register 

        transfer_complete();                        // wait until transfer is complete

       

        I2C1_C1 |= I2C_C1_RSTA_MASK;                // repeat start condition 

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

        I2C1_D = slaveID_read;                        // read address  

        transfer_complete();                        // wait until transfer is complete

        I2C1_C1 &= ~I2C_C1_TX_MASK;                    // receive mode

        I2C1_C1 |= I2C_C1_TXAK_MASK;                // no acknowledge needed

        data = I2C1_D;                                // dummy read to start receiving

        transfer_complete();                        // wait until transfer is complete

        I2C1_C1 &= ~I2C_C1_MST_MASK;                // send stop condition

        data = I2C1_D;                                // read out data  

        I2C1_C1 &= ~I2C_C1_IICEN_MASK;                // disable I2C0

       

        return data;

}

void transfer_complete(void)

{

    char test = 1;

    while (test)

    {

        if (I2C1_S & I2C_S_TCF_MASK)

                {

                    test = 0;

                }

    }

}




0 件の賞賛
返信

1,350件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Just an idea: do you have I2C pull-up resistors present?

0 件の賞賛
返信

1,350件の閲覧回数
andy87
Contributor II

Jep i have:).

I have completly the same with the I2C0-Interface, and here it works.

0 件の賞賛
返信