I received a FRDM-KL46Z board, so here is an extremely quick review/set-up guide for those considering it.
Introduction
There are several boards in the Freescale FRDM family, geared toward their Kinetis ARM processors. The nice thing is that they are extremely low cost and also integrate a few interesting Freescale sensors on each board. It really saves time if you are planning on evaluating one of the sensors but the board can be used as a general purpose microcontroller board. I think anyone considering an Arduino should also seriously consider a FRDM board and not just because they are designed with a similar footprint.
The Kinetis range includes ARM M0+ cores in the Kinetis ‘L’ series (other series’ use different ARM cores). The diagram here (from the reference manual) shows the range offered within the ‘L’ series. It’s interesting that the possibility exists for small 16-pin devices in the future (I don’t think they are available currently).
The KL46Z board contains a 256Kbyte FLASH, 32Kbyte RAM processor. More specifications on the board are here.
The ‘mixed signal’ aspect referred to in the diagram is very interesting; it’s not just a simple ADC or DAC. The microcontroller has an on-board 16-bit ADC with some unusual capabilities not normally seem in microcontrollers; for example it offers differential inputs (ideal if there is any common noise on top of wires connecting to the sensor) and better (higher SNR) for very small signals if the sensor supplies a differential output. Interestingly a hardware trigger capability is also available to acquire the samples at an externally defined point in time. Depending on configuration, it looks like it is possible to configure the ADC to operate at very high speeds (millions of samples per sec) – although I need to study the reference guide more to confirm this; it should really be on Freescale’s product page as a competitive advantage but it isn’t. There are some other analog features (including a DAC) inside the microcontroller that would be worth investigating.
The built-in LCD controller is also great; LCD displays without controllers can be lower cost of course, and the microcontroller can drive the complex multi-level waveforms needed for multiplexed LCD displays. The display on the FRDM board is just a 4-digit model but it would be possible to drive much larger multi-character (e.g. 14-segment) LCD displays (to a total of 376 segments).
Initially Using the Board
The only thing needed is a USB cable (not supplied) to connect to the PC. As soon as that is done, the board appears as a USB drive and the PC starts to install additional drivers. On Windows (Linux drivers are also available but I had no chance to try them), you will most likely get an message that a driver is not available; in that case, there are two options:
1. Go into Device Manager and right-click on the uninstalled device and point it to the USB drive to install the driver (this was in the user guide – I did not try this option)
Or
2. click here to download the OpenSDA drivers (I chose this option, just in case the USB drive contained old drivers)
It installed well; no need to unplug the cable or reboot.
As soon as the board is powered up (via the USB), the demo code runs.
Demonstration code
The demo is absolutely superb; it provides a very nice demonstration of various (not all) sensors. First it starts counting on the screen, until SW1 is pressed. One of the first sensors that the demo shows is the slide/touch sensor, and the position is recorded on the LCD (as a number between 0 and 99). By pressing SW1 (to the right of the sensor) the next demo starts which allows you to see the magnetometer working; rotate the board and it will provide a bearing from North in degrees, on the LCD display with a very rapid update. (When this demo first starts up, it displays a ‘C’ on the screen and some digits; this is the calibration phase and you need to move the board around for a few seconds until the C disappears).
Pressing SW1 again revealed a demo that was not in the user guide; this one provides a darkness level indication (there is a phototransistor mounted close to SW1).
Reading Material
To get to know the board, follow this link and click under “Jump Start Your Design” for access to the Quick Start Package (which contains a quick start PDF and also contains some precompiled applications which unfortunately don’t work – see later) and then download the Design Package which contains the schematics amongst some other things (check the back of the KL46Z for the schematic revision – mine was SCH-27822 Rev C).
The actual processor data sheet is here containing the electrical specs (it is called KL46P121M48SF4 and as good as Freescale documentation is, it is next to impossible to be sure that this is the correct manual until you download it (Freescale, please place the full description under it, i.e. it should say "KL46 Sub-Family Data Sheet - Supports the following: MKL46Z128VLH4, MKL46Z256VLH4, MKL46Z256VMP4, MKL46Z128VLL4, MKL46Z256VLL4, MKL46Z128VMC4, MKL46Z256VMC4" and the full reference manual (close to 1000 pages) is at the same link but click on Reference Manuals at the left - the name is KL46P121M48SF4RM and the description ought to say “KL46 Sub-Family Reference Manual - Supports: MKL46Z128VLH4, MKL46Z256VLH4, MKL46Z256VMP4, MKL46Z128VLL4, MKL46Z256VLL4, MKL46Z128VMC4, MKL46Z256VMC4” to make it clear but today it doesn't.
Compiling and Running Code
The (possibly) most popular board in the FRDM range is the FRDM-KL25Z and it requires no software install (beyond a USB driver) because software can be developed and compiled online using the ‘mbed.org’ cloud-based application (this is not mandatory to use the board).
If you’re familiar with the KL25Z board then you’ll know that once the code has been built, it can be programmed onto the board in one very easy step – the file is just dragged onto the USB drive and the program will download and begin executing within seconds (the file will then disappear from the USB drive view as part of the process, but it will be programmed into the microcontroller).
It is super-fast, and combined with mbed is a game changer in terms of ease-of-use. Much like the BeagleBone Black has adopted USB as an initial method of getting started with the board, this is a nice trend.
Although the KL46Z board also supports the file drag method to program it, there is currently no support with mbed, so a local toolchain will be needed to build the code first. There are many options of course, I went with Freescales’s CodeWarrior because I’ve used it before with a different processor and I liked the IDE in the past.
CodeWarrior
Unfortunately it seems the IDE is now Eclipse-based (some people may prefer that). Personally I found the ‘Classic’ IDE was far simpler than Eclipse and therefore easier to use. CodeWarrior can be downloaded here.
Note that you may be tempted to try some of the precompiled applications (they are in S record format – ending in .srec) that were part of the quick-start bundle; some of these had the word ‘tower’ in them which may refer to Freescale’s tower system, so I did not try them; I tried one which didn’t work, and then noticed that the demo application that is part of the bundle didn’t work either! The board would do nothing. So, it is not possible to revert back to the demo application (the board is not bricked, just that the demo code file does not work). The conclusion was that the bundle was simply old (the demo application was dated 26th June) and the board may have changed. Freescale, please could you provide an updated Quick Start Package, or at least an update demo srec file in the interim.
Building the demonstration code
I attempted to build the demo source code. There is a set of example code available only from the element14 site as far as I am aware. It is nice that Freescale has offered this before it is even on their website. It takes some jumping through hoops to make it work, because there are no instructions with it. By trial-and-error it was possible to import the code, but the folders are very messy.
For starters, CodeWarrior prefers to install in C:\Freescale
rather than C:\Program Files
. Since Freescale
was the preferred folder, I didn’t feel comfortable changing it in case some example code relied on that path.
Here are the main steps I used, in case others want to install it:
My workspace setting for CodeWarrior was:
C:\root\projects\CW_space
The downloaded example code was imported into a subfolder called FRDMKL46_Demo
, but the action did not populate the source code into the same workspace, and it expected it to be placed reference back 4 folders i.e. ../../../..
that would make it C:\src
, C:\tools
, C:\utils
and C:\build
which is not acceptable. The project settings could be altered, but the project uses a lot of include file settings which is slightly inconvenient (i.e. the code could have just used relative paths in the #include
lines to prevent this). The next problem was generating an srec format file instead elf. I couldn’t get to the bottom of why this didn’t work (the option was grayed out even though it appeared configured in the project properties), and so the elf file had to be manually converted using the command line:
cd “C:\root\projects\CW_space\FRDMKL46_Demo\FLASH”
"C:\Freescale\CW MCU v10.4\Cross_Tools\arm-none-eabi-gcc-4_7_3\arm-none-eabi\bin\objcopy.exe" –O srec FRDMKL46_Demo.elf FRDMKL46_Demo.srec
The built code half-worked; it got further than the pre-built version, but not all demonstrations worked, which makes me believe the code is old. When run, the counter display worked, and the capacitive slider functions too, but pressing SW1 again causes the board to freeze and the magnetometer and light sensor demonstrations cannot be executed.
The built srec is attached as an interim measure if needed, but hopefully Freescale can update the Quick Start Package or provide a working demo srec file urgently!
Also, it would be great for Freescale to:
1. Provide step-by-step instructions on how to import the demo source code into CodeWarrior using sensible file paths
2. Provide an explanation of what CodeWarrior functionality expires after 30 days and if it will significantly impact users from continuing to write build and debug applications (EDIT: also see comments below)
3. Provide a makefile as part of the demo source code, so that users can simply use GNU tools (either on Linux, or using the GNU tools that are part of the CodeWarrior install).
On-Board Programmer
This was not mentioned earlier because the behaviour is handily quite transparent to anyone who just wants to program and run code on the board.
A good thing about all the FRDM boards is that they contain an on-board programmer (and debugger!) known as OpenSDA. It is possible to use this to program microcontrollers on other boards. Note that no cable is supplied for this and the connector is extremely tiny for a through-hole device (1.27mm pitch); a pre-built cable from other manufacturers is quite expensive so you may wish to just purchase the connector and solder some wires to it yourself. A track also needs to be cut (under holes marked J18 on the KL46Z, or J11 on the KL25Z) which can be populated with a jumper whenever it is required to revert to local programming behavior). The photo below shows the connector (Farnell part code 1022305) soldered onto a KL25Z board with a normal 0.1-inch header to the right of it for comparison. It really is a very tiny connector (in the center of the photo). The mating connector is this part and is shown on the left (I plan to just directly solder wires to it and protect with some epoxy, for a low cost adapter cable).
Using the Debugger
I only had some limited time to explore the debugger.
As software has become more sophisticated, debugging capability can be needed at multiple levels, such as at a low level with OpenSDA or at a low level within code (such as try..catch, printf statements and so on) or at a higher level within software libraries. OpenSDA allows you to run/pause/stop code execution on the microcontroller and observe what line your C code has got to, view variable contents and so on. It also allows you to see the disassembled code, contents of memory and so on. OpenSDA capability is integrated into CodeWarrior.
Here are the steps to begin using OpenSDA (these are not documented very well anywhere, and I hope someone produces a more detailed guide).
Understanding the OpenSDA capability on the FRDM board
The FRDM boards have two microcontrollers. One is dedicated to OpenSDA (we’ll call it the control microcontroller). The other is the main flagship device (Kinetis ‘L’ in this case) that the FRDM board uses to run the user applications (i.e. your compiled and built programs) – we’ll call it the target microcontroller. The USB connector is connected to the control microcontroller.
When powered up, the USB capability of the FRDM board operates in a ‘Mass Storage Device’ (MSD) mode, which allows the board (the control microcontroller actually) to look like a USB memory drive, so that you can drag and drop built programs onto it. When this occurs, the control microcontroller automatically resets the target microcontroller (i.e. the Kinetis ‘L’ microcontroller) and programs it and then resets it to allow it to start running.
When you wish to debug applications using OpenSDA, the control microcontroller needs to be reprogrammed so that it doesn’t run the MSD function, but runs a debugger function. To do this, first hold down the switch closest to the USB connector and plug in the USB cable to power up the board. The board will still appear as USB memory, but titled ‘BOOTLOADER’. This means that if you drag any program onto the USB drive, it will get programmed into the control microcontroller, not the target microcontroller.
There are also some existing files in the USB drive. One of these (called SDA_INFO.HTM) will connect to a website which will recognize your board, and will allow you to download the latest OpenSDA Firmware.
This is the website you will see, download the 'Firmware Apps' zip file:
When you extract the file, it will contain many files; the only ones needed are DEBUG-APP_Pemicro_v108.SDA and MSD-FRDM-KL46Z48M_Pemicro_v112.SDA.
Drag the DEBUG-APP file onto the USB memory, and it will program the control microcontroller. Then, disconnect and reconnect the USB cable. Now, in CodeWarrior, right-click on FRDMKL46_Demo in the projects pane and select Debug As->Debug Configurations. In the window that appears, on the left side, expand ‘CodeWarrior Attach’ and select the item inside it. On the right side there is a Connection drop-down where the arrow looks grayed out, but you can actually click it and select OpenSDA. Repeat for the ‘CodeWarrior Download’ option too, as shown here.
In the main CodeWarrior window, at the top-right, there are two ‘perspectives’ – C/C++ and Debug – this is what it looks like:
Clicking on Debug will bring up a new view, where you can go to Run->Debug in the menu, to launch your debug session. Then you can click on the resume button to start the program, or terminate to stop it:
Here is a view when the pause button (between resume and terminate was pressed). You can see in the center left pane where in the C code the program has got to, and in the center right pane a disassembly listing. The top left pane shows a ‘stack trace’ type of view which shows (from bottom-up) that the C startup code called start()
in the file start.c, which then executed the main()
function which called task_test_lcd()
. This is just scraping the surface of the debugger.
After you're done with the debugger and wish to revert back to the usual mass storage device functionality on the FRDM board, you'll need to hold down the reset switch again and power up the board so that it appears as BOOTLOADER again, and this time drag the MSD-FRDM-KL46Z48M_Pemicro_v112.SDA file onto it. This will program the control microcontroller back into the non-debug mode.
Conclusions
This is a superb board; the display and the fact that it is a very powerful CPU with some excellent ADC and DAC features means that I can see myself purchasing several of these for dedicated tasks; one example would be a data logger, where a built-in low-power display is very beneficial. The board has incredible value for money (list price is £9.94 currently here). Note that the microcontroller has many other on-chip peripherals not discussed here.
Without mbed, it would be nice to have some more hand-holding from Freescale to show users how to begin programming for it because users should not have to guess how to set up paths for installing the compiler and code, and srec should be enabled by default in the supplied project settings file. Thankfully these are easy things for Freescale to do.
Until then, the KL25Z is the best introduction to the series; if you’re purchasing these boards, you may want both or more; I have already decided to also experiment with a Kinetis ‘K’ series board too for higher performance scenarios.
Top Comments