KL03 struggling to set up a bare metal ksdk application

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

KL03 struggling to set up a bare metal ksdk application

1,463 Views
tedmawson
Contributor III

I have designed my own board that uses a MKL03Z32CAF4R processor.

 

I'm using KDS 3.1.0 and KSDK 1.3.0 and I want to create a simple bare metal application that operates the GPIO pins and reads an A2D on PTA9.  I tried to find an example of how to do this that wasn't related to a development board but the nearest I found was the pdf at the bottom of this link Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt which is for KSDK 1.2.0 and may not work for KSDK 1.3.0.  got as far as adding the /Board directory and copying the files across into it but gpio_pins.h contains a #include "fsl_gpio_drvier.h" that is giving a not found fatal error even though I've added a path to the Includes of C:\Freescale\KSDK_1.3.0\platform\drivers\inc

 

A. Will this KSDK 1.2.0 example even work with KSDK 1.3.0 ?

B. Is there not a simpler way to achieve my aim?

 

I'm frustrated that there are all these cool fsl_xxx drivers that I can open and understand but it's far from clear in the documentation how to add them to a bare project.

 

Thanks

Labels (1)
Tags (2)
8 Replies

817 Views
dereksnell
NXP Employee
NXP Employee

Hi Ted,

The KSDK includes a clock manager to help with this. Yes, the clock sources and frequencies for the MCU can be changed dynamically, and the clock manager includes APIs to do this at runtime.  KSDK includes a low-power example that also includes using the clock manager to change the MCU core frequency.  The example is installed at \KSDK_1.3.0\examples\frdmkl03z\demo_apps\power_manager_hal_demo

At boot, the KSDK sets up the clock in the start-up code. This is done early in the start-up process, before main() is executed.  Those clock settings are setup in startup system header file.  For the KL03, this file is \KSDK_1.3.0\platform\devices\MKL03Z4\startup\system_MKL03Z4.h.  That file uses macros for the clock configuration.

In addition to the KSDK documentation, the link below is a KSDK training.  The training presentation includes more information on the clock manager, and how to use it, with more details in the Lab4 lab guide.  And Lab5 lab guide walks through using Processor Expert to change the clock configuration for KSDK, and update the system_<device>.h startup file.  Even if Processor Expert is not used in your application, it is a quick tool to setup the clock configurations.  After the new files are generated, you can copy them into your KSDK application project, as discussed at the end of Lab5.

MQX for KSDK Training 2015-September.zip

Also, NXP is working on a new Clock Configuration tool for KSDK.  It will be part of the Kinetis Expert tools available this summer at kex.nxp.com

Thanks

0 Kudos

817 Views
DavidS
NXP Employee
NXP Employee

Hi Ted,

Have you reviewed the "Kinetis L Peripheral Module Quick Reference" PDF?

http://www.nxp.com/files/32bit/doc/quick_ref_guide/KLQRUG.pdf 

Regards,

David 

817 Views
tedmawson
Contributor III

David, I've only just started reading this but it looks like it is what I need - thank you!

0 Kudos

817 Views
dereksnell
NXP Employee
NXP Employee

Hi Ted,

Yes, you should not check the box to “copy project into the workspace”.  When that option is used with Eclipse, it will break all the linked references to the source files outside of your project directory, like all the KSDK source files.

You should be good to start coding now.  Thanks

0 Kudos

817 Views
tedmawson
Contributor III

Derek, I managed to get a KSDK-generated project running in KDS after a bug in Eclipse slowed me down for half a day.  I have the GPIO figured out but I'm struggling with the clock, I know what I want to do but it's not clear what the simple steps are to set up a clock and whether it's OK to change it while running.  One issue is that all the example programs run on the external oscillator but I want to run my device of the internal clock generators.  Any documentation you can point me to?

0 Kudos

817 Views
dereksnell
NXP Employee
NXP Employee

Hi Ted,

The difference between KSDK v1.3.0 and v1.2.0 is mainly adding new device and board support.  The KSDK framework didn’t change much, and the tutorial you reference for KSDK v1.2.0 should also work with KSDK v1.3.0. 

But there is an easier way now using the KSDK Project Generator.  That tool allows you to generate new projects for the KSDK, or clone the example projects. This will create a new KDS project for you, doing most of the steps in that tutorial, and it will setup the include paths for you.  It’s available for download from the KSDK Downloads page.

As for your project error, the include path looks correct for the driver include files.  Is it possible your KSDK is installed in a location other than the default C:\Freescale\KSDK_1.3.0?  If that’s not it, then it must be an issue in the KDS project settings.  Can you share the full error from KDS in the Console view and a screenshot of the C Compiler include path settings in KDS?

Thanks

0 Kudos

817 Views
tedmawson
Contributor III

Derek,

I tried the KSDK Project Generator once before, it didn’t seem to work so I assumed it was broken.  Let’s see if you can help me get it working?

First I ran the tool and used the advanced functions. I selected:

1.      Gave project a name

2.      New

3.      Platform

4.      No RTOS

5.      Device MKL03Z32xxx4

6.      And I checked include BSP files (I think this will be useful)

7.      Selected the box to generate a standalone project

8.      After generating,  I had what looked like a full set of files in C:\Freescale\KSDK_1.3.0\examples\frdmkl03z\user_apps\ PRMv2_PG2 – I could see the main.c and main.h files and all the files in the board folder

9.      I ran up KDS and imported the project into KDS and checked the box to copy the files into the project workspace

10.  It looks like the project is there in KDS but any file I try to edit e.g. main.c, I get a blank window with the words ‘Error retrieving content description for resource ‘/PRMv2_PG2_MKL03Z32CAF4/sources/main.c’. It’s the same for all the .c or .h files in any folder.  I tried cleaning but still the same

Any ideas?

Ted

0 Kudos

817 Views
tedmawson
Contributor III

Derek,

I just retried my steps above but, when importing into KDS, I did NOT check the box to 'copy the project into the workspace'.  Now I see the project, can open and edit main.c, and the project seems to build without errors although it has none of my code in it.

Do you think I'm good to start coding?

Ted

0 Kudos