AnsweredAssumed Answered

FRDM board I2C funny question :)

Question asked by kazola on Mar 28, 2014
Latest reply on Apr 2, 2014 by MB JK

Hi!

It is my first time in the freescale community Let's hope we can do lots of work together

 

1)

I just bought my KL05Z Freedom platform. It is quite nice. However, as other people says, there is very few documentation and examples and certainly even less for this KL05Z.

And some of them are not even properly prepared if you work with CodeWarrior

So my first question goes in this direction. Is there any plans or any hidden folder I have not seen to solve this lack--of--examples issue?

 

2)

Are there other docs, apart of the long datasheet, to learn about the low-power modes and other stuff like GPIO init for minimum consumption for my board?

 

3) Finally, and the core of this thread is about I2C I have the following code for some sort of I2C "ping":

 

static void pause(void) {

    int n;

    for (n = 0; n < 40; n++)

        ;

    //  asm("nop");

}

uint8 hal_dev_scan() {

    uint8 result;

    uint8 unshifted_address = 0;

    uint8 i2c_address = 0;

 

    for (unshifted_address = 1; unshifted_address < 127; unshifted_address++) {

        // to put address in I2C bus, shift

        // accel I2C unshifted_address = 0x1D << 1 --> i2c_address = 0x3A

        i2c_address = unshifted_address << 1;

 

        i2c_start(I2C0_B );

        i2c_write_byte(I2C0_B, i2c_address | I2C_WRITE);

        i2c_wait(I2C0_B );

        result = i2c_get_ack(I2C0_B );

        i2c_stop(I2C0_B );

        pause();

   

        if (result)

            printf("\tfound I2C device, unshifted_@ = 0x%.2X, i2c_@ = 0x%.2X \n", unshifted_address, i2c_address);

    }

 

It works quite well. When calling hal_dev_scan() I was only expecting the accelerometer I2C address and my own EEPROM I2C address to appear. However:

     found I2C device, unshifted_@ = 0x1D, i2c_@ = 0x3A <-- accel i2C address, that is ok

     found I2C device, unshifted_@ = 0x2D, i2c_@ = 0x5A <-- what is this?

     found I2C device, unshifted_@ = <-- in here there are my EEPROM values,  that is ok

 

There are three of them In fact, if I remove the "pause()" line, the medium line does not appear.

So, this is my first question with my first Freescale board What am I doing wrong or not considering? Why is pause() provoking this?

 

4) Last question. Is there any way to format code in this forum in order to appear better?

 

Let me know your opinions and many thanks in advance!

Outcomes