FRDM board I2C funny question :)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM board I2C funny question :)

Jump to solution
2,876 Views
kazola
Contributor III

Hi!

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

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 :smileygrin:

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 :smileyhappy: 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 :smileyhappy: 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 :smileyhappy: 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!

1 Solution
1,103 Views
perlam_i_au
Senior Contributor I

Hi Kazola!!! and welcome to community!!! :smileygrin:

At this moment I have found some answers to your questions, I will follow your order to make it clear:

1.- You probably has been looking for example codes on the FRDM-KL05Z: Freescale Freedom Development Platform for the Kinetis KL05 and KL04 MCUs page, in the "Downloads" tag, on the "Software development tools" is the KL05-SC sample code package, on these package you will find different examples for CodeWarrior, IAR and Keil.

Also you can go to the KL0: Kinetis KL0 Entry-Level MCUs page, on the "Software and tools" tag, here you will find:

May be you have seen some of these documentation, but if don't I hope you find it useful.

2.- There are some application notes that you can use to check how works and how to configure Kinetis micsrocontrollers to work on low power modes, I would like to suggest you some of my favorites:

3.- Well I need to check this carefully, it take me a bit of time, please be patient

4.- Regard format code, there is anything written about it, you can use the advanced editor if you prefer, here you will find extra features that can help you to order your post

Welcome again!! and please keep in touch!!! :smileyhappy:


Have a nice day :P,
Perla

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

6 Replies
1,103 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kazola,

       About your question 3, you can use the logic analyzer to grab the communication waveform, and to see whether the address 0x5A is the real ACK. and compare the waveform which is delete the pause().

      Wish it helps!

Best regards!

Jingjing

1,103 Views
kazola
Contributor III

Hi Jingjing Zhou,

indeed I will :smileyhappy: Good idea. I remember I have a BusPirate somewhere.

Many thanks for your time!

1,103 Views
perlam_i_au
Senior Contributor I

Hey!! I have been reviewing the FRDM-KL05Z schematic and the only I2C connections in this board are in Arduino Uno Comatible Shields and the I2C inertial sensor. Based on this I guess you may be have another thing connected to the PTB3/IRQ_14/I2C0_SCL/UART0_TX and PTB4/IRQ_15/LLWU_P6/I2C0_SDA/UART0_RX lines on Arduino Shield. :smileysilly:

0 Kudos
1,103 Views
kazola
Contributor III

Hi Perla,

many thanks for your time. Indeed, I do not work with any Arduino or have anything attached but a second device :smileywink: But I will check with a loging analyzer as suggested below.

Regarding the other answers, they are very useful, thanks for the links. Usually Application Notes go much more to the point when starting with new MCUs.

Have a really nice day!

1,104 Views
perlam_i_au
Senior Contributor I

Hi Kazola!!! and welcome to community!!! :smileygrin:

At this moment I have found some answers to your questions, I will follow your order to make it clear:

1.- You probably has been looking for example codes on the FRDM-KL05Z: Freescale Freedom Development Platform for the Kinetis KL05 and KL04 MCUs page, in the "Downloads" tag, on the "Software development tools" is the KL05-SC sample code package, on these package you will find different examples for CodeWarrior, IAR and Keil.

Also you can go to the KL0: Kinetis KL0 Entry-Level MCUs page, on the "Software and tools" tag, here you will find:

May be you have seen some of these documentation, but if don't I hope you find it useful.

2.- There are some application notes that you can use to check how works and how to configure Kinetis micsrocontrollers to work on low power modes, I would like to suggest you some of my favorites:

3.- Well I need to check this carefully, it take me a bit of time, please be patient

4.- Regard format code, there is anything written about it, you can use the advanced editor if you prefer, here you will find extra features that can help you to order your post

Welcome again!! and please keep in touch!!! :smileyhappy:


Have a nice day :P,
Perla

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,103 Views
mbjvfx
Contributor II

Thanks for sharing your links, Perla.  I too have had a challenge in finding working code for CW to get up and running with the freedom boards using bare-metal designs.

Here are a couple of additional links to what I have found to be extremely useful to understand the base architecture, IRQ, peripherals working up to some very cool application code.  This was put together by Eli Hughes (Thank you!)  and there are full youtube videos explanations and source code projects for CW. 

The Book of Eli - Microcontrollers, robotics and warp drives

Additionally it appears that Eli is gearing to do some very cool projects using the same manner of video explanation and working source code.  Applications with more advanced functions such as DSP, DMA,etc.  Looking forward to his progress on this. 

Freescale Hack It Together (H.I.T.) Project Initiative - Get Excited!

I hope that these links might be as helpful to other beginners using kinetis as they were to me.  Maybe someone could put together  a "useful links" or "educational links" that these types of materials could be accessed by users? 

0 Kudos