Coding FRDM-Kl25z

23 Jun 2013

Hi I am new to embedded and new to programming FRDM-Kl25z and I have to do a simple project using FRDM-Kl25z. Can anyone please let me know which textbook can i refer to gain knowledge about basics for programming this device quickly and start trying out sample programs. Thanks.

23 Jun 2013

Minus the pin names you can use almost all examples for all boards. Here are a bunch of example programs you can directly use on the KL25Z: http://mbed.org/handbook/mbed-FRDM-KL25Z-Examples

23 Jun 2013

Hi Erik. thanks for your reply.. I tried this example I changed the LED_GREEN as LED_BLUE but the light color is different...it is not displaying blue after 2sec..it showing red or green ..I am not sure whether the output is correct or wrong and I am not sure how to proceed after this... if possible can you please help me with basic programming links with explanation... thanks.

  1. include "mbed.h"

int main() { DigitalOut gpo(PTB8); DigitalOut led(LED_GREEN);

while (true) { led = 0; Off wait(2); led = 1; on wait(2); } }

23 Jun 2013

Put code between <<code>> and <</code>>, that makes it readable.

I don't have the KL25Z board myself, but if you change LED_GREEN to LED_BLUE, the blue led should blink. Do take into account that due to the connections a LED will go on if you output a 0, and off when you output a 1.

But what exactly did you do? Since that code has nothing related to LED_BLUE.

24 Jun 2013

Hi Erik- Thanks for your reply.

I compiled a very simple code using mbed compiler...

include "mbed.h"

int main() {
      DigitalOut led(LED_RED);

    while (true) {
        led = 0; // Off
        wait(2);
        led = 1; // on
        wait(2);
    }
}

so after compiling this code I got the output as tricolor led flashing red for 2 ms.so I changed the digitalout led as green and blue(as LED_RED,LED_BLUE) so it displayed corresponding colors.

Next I thought of flasing all the three colors one by one for that I wrote the code as

#include "mbed.h"

int main() {
   
    DigitalOut led1(LED_RED);
    DigitalOut led2(LED_BLUE);
    DigitalOut led3(LED_GREEN);

    while (true) {    
       led1 = 0; // Off
       wait(60);
       led1 = 1; // on
       wait(60);
       led2 = 0; // Off
       wait(60);
       led2 = 1; // on
       wait(60);
       led3 = 0; // Off
       wait(60);
       led3 = 1; // on
       wait(60);
        
    }
}

But I am not getting the colors flashing one by one I think it is flashing all at once... I changed the wait sec as continous too...(like (60,120,180 and so on) and I also tried like this... while flashing red led, I even assigned one(it means off rt?) for the rest of the led variables.

I don't know where I am doing mistake.. If possible can you please help me with this issue.. Thanks a lot.

Regards BP.

24 Jun 2013

You know wait is in seconds? Wait_ms is for milliseconds, so now it waits 60 seconds before doing anything. That and '0' and '1' are inverted for this board regarding LEDs on and off. (Normally you define the leds above main, although this works too).

But if you use this code with shorters waits it should do what you want it to do. (After the first cycle, initial condition is now that they are all on).

24 Jun 2013

Hi Erik- Thanks for your reply. I corrected my code as

#include "mbed.h"

int main() {   
   
    DigitalOut rled(LED_RED);
    DigitalOut bled(LED_BLUE);
    DigitalOut gled(LED_GREEN);     

    while (1) {    
    rled = 0;
    gled = 1;
    bled = 1;
    wait(0.2);
    rled = 1;
    gled = 0;
    bled = 1;
    wait(0.2);
    rled = 1;
    gled = 1;
    bled = 0;
    wait(0.2);  
    }
}

I typed the pgm in mbed compiler and clicked the compile button after that it is creating .bin file so I saved it using 'save as' in my mbed folder.

Immediately the output is reflected in my evaluvation board and only with red light flash. the output is not continously flashing red blue green...

I don't know where i am making the mistake... if possible can you please help me with this issue

Thanks & Regards

B P

24 Jun 2013

Well thats weird. Either you are mistaken and the program isn't loaded, or it went into an error state: The KL25 will flash red when an error has been encountered (not all errors, just errors within the mbed library, such as trying to make a serial port on pins that cannot be a serial port).

If it is indeed an error they generally report via the USB serial port (the same one as you use to upload the program) what the error is. Can you follow http://mbed.org/handbook/SerialPC, and run your code while a terminal program is connected to your KL25? Then maybe it gives an error message.

Just to make certain I am not going crazy I compiled that code for an LPC1768 (just different led names), and it works fine. Sadly I don't have a KL25 so can't try that directly.

25 Jun 2013

Hi Erik-

Thanks for your reply and information about Serial PC. It seems interesting I will try it.

actually it is working now... I unplugged the KL25Z and when I reconnected it now the led started flashing tricolors!!

Should I have to unplug after saving .bin and plug it again to see the output? Also I have another question I downloaded code warriors IDE ...I can also program KL25Z using code warriors or it is not needed if I use mbed compiler?

Thanks for your time. Regards B P

25 Jun 2013

Ah yeah, you will need to reset the board after uploading new program.

And you can use Code Warrior IDE, it will also be able to make a bin file that you can put on your board. However then you lose the advantage of mbed library. If you export your mbed program you can see which offline compilers currently are supported by mbed for KL25. Then you can compile it offline and still use the mbed libraries.

25 Jun 2013

Hi Erik-

Thanks for your reply!. I am comfortable in mbed compiler itself ...For now I am going to stick with mbed compiler Itself.. I can do all kind of application in mbed as well as in codewarrior rt? Is there anything I cannot do in mbed or it will be easier to do in Code Warrior?

Next,I would like to control the LED through switch...like if I press a button it should be on with some color and when I don't press the button, it should be off. the only button I have in KL25Z is reset(rt?), can I use the reset button to do the operation... how the system will recognize that I am not pressing it for reset...

Since I am new to this board I am really worried that I can do this program this way or can I try it in some other way.. because I don't wanted to fail the device..

If possible can you please help me with this issue.. Thanks for your time. Regards B P

26 Jun 2013

Hi Erik-

I downloaded the device driver for serial pc it is successfully installed. but if I run a simple hello world program i am not getting the output display in my PC. I am running on a windows vista computer, I checked the control panel and the port is COM5. Is there anything Ineed to do before executing the program?..I even reconnected the evaluation board... If possible please help me with this issue...

Thanks & Regards B P.

26 Jun 2013

I don't have the KL25Z myself. So I don't know if a LED shows serial activity like on the LPC1768 for example. You installed serial drivers with the KL25 plugged into your computer via the same USB port you upload programs? You are using this program? http://mbed.org/users/mbed_official/code/FRDM_Serial/file/eea88312499a/main.cpp

The green led blinks also? And you got teraterm running connected to the mbed com port?

16 Jul 2013

I am doing a project using FRDM-KL25Z evaluation board. I am planning to control a simple motor using this evaluation board. I am unable to find the right motor and a motor driver, that could be used with this evaluation board. If possible if any of you know of any motor and driver that I can use with this evaluation board, can you please let me know?

16 Jul 2013

An advantage of the KL25Z is that it should be compatible with Arduino shields, so you can get an arduino motor driver shield and put that on the KL25Z. Of course you can also just use a breakout board for example for most other motor drivers. What is important is checking they work with 3.3V.

17 May 2018

Does anyone know how to program the frdm-kl25z to make an led blink when it falls? Also, how can it be coded to count steps?

Really need help on this one