10 years, 9 months ago.

How to enable internal Pull UP resistor of I2C(SCL,SDA) in FRDM - KL25Z?

When I run the I2C program in the FRDM - KL25Z, am not getting 3.3v in SDA, SCL pins with respective to the ground. How to enable the internal pull up resistor.? I have checked with the Raspberry Pi with IO chip, and its working fine.

Otherwise can i use the external pull up resistor. I have attached my program pls check that too.

/media/uploads/krishna10061990/i2c1_tca9535.cpp

1 Answer

-deleted-
10 years, 9 months ago.

Duplicate question: http://developer.mbed.org/questions/6711/How-to-enable-internal-Pull-UP-resistor-/#answer6822

I found this thread related to pull-up resistors: https://developer.mbed.org/questions/787/FRDM-KL25Z-I2C-Problem/

It seems you need to add external pull-up resistors to both SDA and SCL signals. You can use either 2K2, 3K2 or 4K7 connected between the SCL pin and 3v3 pin, and also SDA pin and 3v3. 4K7 resistors are most common.

I looked at the schematic: http://cache.freescale.com/files/soft_dev_tools/hardware_tools/schematics/FRDM-KL25Z_SCH_REV_E.pdf and found 4K7 pull-up resistors on I2C0_SCL (PTE24) and I2C0_SDA (PTE25) which connect to the onboard inertial sensor (MMA8451Q). Pins PTE24 and PTE25 are additional peripherals as described here: http://developer.mbed.org/platforms/KL25Z/

In summary I2C1_SCL (PTC8) and I2C1_SDA (PTC9) do not have pull-up resistors. This is also true for PTE29 and PTE30.

If you add external pull-up resistors you should have success.

I did not test the code:

#include "mbed.h"   

Serial pc(USBTX, USBRX);

I2C master(PTC9, PTC8);

main()
{
    pc.printf ("i2c program starting\n");
    int i;
    int address = 0x26;
    const char data[] = { 0xff, 0xff };
    int length = 2;
  //  bool repeated = false;
    
    master.frequency(300000);
    master.start();

    i = master.write(address, data, length);
     
    pc.printf ("%d\n", i );
    master.stop();
}