Introduction: Getting Started With - FreeScale K64f

Picture of Getting Started With - FreeScale K64f

Today I just got a Freedom K64F form FreeScale, this is a cheap alternative of Arduino and can do a lot what an Alrduino can't. In this Insturctable I'm going to show you how to get started with the K64F and I will explain a little about the classes used.

After using the Arduino a lot followed by the spark core or the particle core as it is now called, I can see a noticeable amount of difference in the classes used to program the board.

The K64F is a low power consuming device with a standby current of 150nA usage, it supports drag and drop programming, and has an on board accelerometer and has a lot of GPIO pins. Here is some technical specification of the board.

  • High performance ARM® Cortex™-M4 Core with Floating point unit and DSP
  • 120MHz, 256KB RAM, 1MB FLASH
  • USB OTG
  • FXOS8700CQ - 3-axis accelerometer and magnetometer
  • Ethernet
  • 2 push buttons
  • RGB LED
  • Micro SD card slot

The K64F supports mbed operating system with interchangeable boot-loader.

Step 1: Requirements

Picture of Requirements

The things you need to know to get started with the board is-

  • C Programming experience
  • A Micro USB cable (Not included in the box, probably to keep up with the low price tag)

Also, it would be helpful if you have used an Arduino before, but that is not a major requirement as I would try to keep this Instrucable as simple as possible.

Note- The classes in Arduino and that of the K64 are different, the arduino experience is just to make you understand easier what you are doing.

Step 2: Plugging It In

Picture of Plugging It In

Now it's time you take the board out of the box and get yourself a micro USB cable. Plug in the USB cable into the Open SDA port. Now the board would flash Red, Blue, Green colors in a loop to you and in your computer, you should see that a mass storage device has been connected with about 1 mb of free space.

The device would be named MBED CMSIS-DAP if you open up your Control Panel => Hardware and Sound => Devices and Printers in Windows PC or just type in lsusb in Linux (It is named NXP LPC1768 in Ubuntu). If the above steps go fine then you have connected your K64F successfully.

Step 3: Registering an Account at Mbed.org

Picture of Registering an Account at Mbed.org

If the previous step went fine now open the mass storage device using a file explorer, the USB storage will be named MBED by default. In the root of the storage you would find a file named mbed.html.

Open up the file in a web browser and you would get redirected to mbed.org where you can register for an account or if you have used it before you can login.

After successfully registering you would see your home screen and on the top right corner you would find Compile, click on that to start the online SDK or IDE. The K64F supports a drag and drop interface which I will be explaining shortly.

Step 4: Blink

Picture of Blink

Time to write a program to the code.

Right click on where it says My Programs and enter in an name you want to call your application in the dialog box. The default program should already been written for you, hit compile on the top of the screen a few bunchs of dialog boxes will show up and if everything goes well you should see a file staring to download.

The file would have an extension of .bin which stands for binary and I have also attached the file in case you don't want to go go through the above procedure right now.

Next just copy and paste the file in the mass storage drive or MBED drive and you should see the board flashing lights when the file is being written and then hit the reset button and if everything went fine the RBG led would be flashing red or blue at you.

Step 5: Pin Names

Picture of Pin Names

After having fun with a blinking led you could go further and make it blink multiple colors, rather that the default red. Here is what the Led Pins are called in the program-

LED (RGB)

LED_RED = PTB22

LED_GREEN = PTE26

LED_BLUE = PTB21

And if you want to hook up an Arduino shield, you can do that and here is the pin names for it-

Arduino Headers

D0 = PTC16

D1 = PTC17

D2 = PTB9

D3 = PTA1

D4 = PTB23

D5 = PTA2

D6 = PTC2

D7 = PTC3

D8 = PTA0

D9 = PTC4

D10 = PTD0

D11 = PTD2

D12 = PTD3

D13 = PTD1

D14 = PTE25

D15 = PTE24

A0 = PTB2

A1 = PTB3

A2 = PTB10

A3 = PTB11

A4 = PTC10

A5 = PTC11

All the information about how the classes or functions are named can be found in the mbed include file which is included in every project, under Mbed => Classes.

I have also attached an spread sheet file in the attachments relating each pin and their name and function.

If you want me to explain all the classes in another Instructable please PM me, stay tuned for more projects relating to the K64 and much more.

Step 6: External LED

Picture of External LED

So far we made the external led blink, now lets make an external one blink. This example demonstrates a GPIO example and the pin names can be found in the previous sheet. In this example code 2 LEDs light up alternatively, one on the board and other in K64F GPIO pin 12.

Here is the code -

#include "mbed.h"
DigitalOut gpo(D0); DigitalOut led(LED_RED); int main() { while (true) { gpo = !gpo; // toggle pin led = !led; // toggle led wait(0.2f); } }

The binary for this code, can be found in the attachments you can also type this up and experiment with the examples in various GPIO examples and if you come up with some error leave a comment below or feel free to PM me.

Comments

Mr.What (author)2015-07-26

I had to press the button near the USB port to run new code after downloading. It is also of note that the LED pin values are kind of "inverted". A logic 0 turns the LED on, whereas logic 1 turns and LED off.

Pointers to more docs would be good. Are all Digital I/O pins PWM capable?

Can I create a Serial (or RawSerial) on any pair of pins... or are there some specuial groups that can do this. Is there a UART... or do they do it all in software?

Just got a demo board, and have been asked to do something with it... still looking for resources.

tomatoskins (author)2015-06-26

Really great info! I've never head of anything from FreeScale. Maybe I should take a look into them.

About This Instructable

9,855views

97favorites

License:

More by LightBug:Getting started with IoT using the Particle CoreFish Food Feeder Using the Linkit OneControlling High voltage devices with LinkIt One
Add instructable to: