KL03 on KDS: Linking C Functions?

cancel
Showing results for 
Search instead for 
Did you mean: 

KL03 on KDS: Linking C Functions?

700 Views
Contributor III

Hello,

I'm using the KL03 in the Kinetis Design Studio environment. I decided to break down main.c code into various functions, such as core_clock_init.c and ports_init.c. I call these functions from within main.c. However, when I run my code, I get the following error related to the linker:

C:/Freescale/KSDK_1.3.0/examples/frdmkl03z/user_apps/Sara_Tiny_Tag_Devel_Board/main.c:79: undefined reference to `core_clock_init'
C:/Freescale/KSDK_1.3.0/examples/frdmkl03z/user_apps/Sara_Tiny_Tag_Devel_Board/main.c:82: undefined reference to `ports_init

Right now these functions are in the same location as the main.c. I have verified that that location is part of the includes.

So, where should I place these files? How do I make the linker see them?

Thanks,

Sara

0 Kudos
21 Replies

10 Views
Contributor III

Just to conclude this thread, I managed to get my code to work with the external functions without having to upgrade. It also turned out that I already have SDK2.0 installed.

Thanks,

Sara

0 Kudos

9 Views
NXP TechSupport
NXP TechSupport

Hi Sara,

 Yes, the new version KDS has install the SDKv2.0 New project wizard.

BR

Alice

0 Kudos

9 Views
NXP Employee
NXP Employee

Hi Sara,

KDS 3.2 contains New Project Wizard for SDK 2.x, but there is update available on KDS update-site. I recommend to update to latest version.

Regards

Marek

Regards,
Marek
0 Kudos

10 Views
Contributor III

Hi Neil,

Thanks for the info. I tried what you suggested, but I get the following error. What does this mean?

That "sources" directory is sort of virtual since I don't see it anywhere in my folder explorer window. The main.ca file sits outside of a bunch of other directories that look nothing like what KDS shows.

Saraerror.png

0 Kudos

10 Views
NXP TechSupport
NXP TechSupport

Hello Sara,

1. Please add the path of header files into Include paths as below :

pastedImage_2.png

If still can't work well,  you can share your project , then I will help you  check it .

Hope it helps


Have a great day,
TIC

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

0 Kudos

10 Views
Contributor III

HI Alice,

I tried what you suggested, but it did not fix the problem. I’m not sure what you mean by “share the project”. I have instead zipped the directory and attached it here. All the functions that I want to use are with the “main.c” program in the Sara_Tiny_Tag_Devel_Board directory (core_clock_init.c, ports_init.c, etc…) .

Thanks,

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
NXP TechSupport
NXP TechSupport

Hello Sara,

- For the KSDKv1.3 always make us confused about the lib and header files path,

and I have check your project , there is many functions and files can't find in your project.

So I strongly recommend you use the latest version of KSDKv2.x ( It is also named MCUXpresso SDK).

In KSDKv2.x, you needn't consider the ksdk_platform.a , and it can automatically includes the drivers (.c and .h).

if you want add some other files made by yourself, just add the .c and .h, include the path as I mentioned last time.

- Below is the steps about how to use KSDKv2.x on KDS3.x :

  1. Please download the KSDK v2.x package for you board or chip refer to this tutorial :

Generating a downloadable MCUXpresso SDK v.2 package 

2. Then refer to this tutorial to create new project (Do not use project generator )or import KSDK example on KDSv3.x:

Using Kinetis Design Studio v3.x with Kinetis SDK v2.0  

3.Then you can call the function under "SDK_2.2_FRDM-KL03Z\devices\MKL03Z4\drivers",

or add your own files.

Hope it helps


Have a great day,
TIC

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

0 Kudos

10 Views
Contributor III

Hi Alice,

Ok. A couple questions before I begin:

1. Will upgrading the KSDK cause all my previous files not to work?

2. When I follow the link, I note that the configuration is specific to either the evaluation board or the chipset. Is there a big difference between the two? I assume that the one related to the evaluation board has lots of header files related to the board whereas the chip will not?

3. Once I have downloaded the .mex files…what do I do? It’s not clear from your email. Is there where I go into KDS and follow the instructions on the second link? They don’t seem to line up.

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
NXP TechSupport
NXP TechSupport

Hello Sara,

  1. After update KSDKV2.0,  your KSDKv1.3 project can also work well on KDS.

While there is some difference between KSDKv1.3 and KSDKv2.0 ,  we can't directly copy the

KSDKv1.3 code to KDSKv2.0 project .

  1. There isn't big difference , yes, the board package includes the board information files .
  2. You need download the .zip folder , not the .mem files, after you click  "I Agree ". please wait some minutes, it will show the download package .

About  the second link , please read from

“Installing Kinetis SDK v2.0 New Project Wizard in Kinetis Design Studio”,

It detailly described how to use KSDKv2.0 on KDS.

Hope it helps

 


Have a great day,
TIC

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

0 Kudos

10 Views
NXP Employee
NXP Employee

Hi Sara,

Eclipse contains its own file system. It means files in the Eclipse Project Explorer does not need to be in the same directories as they are displayed. "virtual folder" means, it is not a real folder on the disk, the folder represents only "named location" that contains links to project source files.

Generally I'd recommend to avoid "virtual folders" in your project due to following reasons:

  • you can easily review the project content on the disk and in the Project Explorer, both contains the same files
  • you can easily backup or share your project (or put to Git), because all source files are in the project folder

Regards

Marek

Regards,
Marek
0 Kudos

10 Views
Contributor III

Hi Marek,

How do I avoid using the virtual folders…the software automatically sets them up! I too would prefer not to use them.

Thanks,

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
Senior Contributor I

Sara,

I like to separate my specific functions in there own folders. It keeps things neat!

Your project folder contains a source folder and a Includes folder.

Source folder contains the .c files

Includes folder contains the .h files

like so,

test.jpg

You can create your function such as Init.c by right clicking  on the Source folder and selecting New->source file and

the same would hold true for Includes-> Header File,  but right click on the Includes file.

like so,

test2.jpg

Neil

0 Kudos

10 Views
Senior Contributor I

Hi Sara,

Did you declare the functions inside your main?

Do you want this functions to exist in your main?

Neil

0 Kudos

10 Views
Contributor III

Hi Neil,

I have not declared them in the main.c and I was not intending them to exist in main.ca.

I’m a little rusty on my C programming…so I must declare the external functions in main.ca? I didn’t because it seems that all the external functions being used in the demo examples are not defined inside main.c.

I believe my problem is related to the linker somehow. I have been looking at the setting under project/settings/Cross ARM C Linker. Not sure what to select though.

Thanks!

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
NXP Employee
NXP Employee

Hi Sara,

can you describe how do you create your project?

Regards

Marek

Regards,
Marek
0 Kudos

10 Views
Contributor III

Hi Marek,

I use the KSDK Project Generator and then import the project into the Kinetic Design Studio. It sets up all the folders for me…all I do is open the main.c and start entering code. All was fine until I decided that I wanted to have external functions called from within main.c.

Any ideas? Attached is my project folder set-up.

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
NXP Employee
NXP Employee

Hi Sara,

there is option "Standalone project" in KSDK Project generator. Ensure the check-box is selected before you generate project. Also ensure you are using latest version of the KSDK Project Generator.

Currently I'm not sure if the option works also for SDK1.3. It definely works for SDK 2.0 packages.

In KDS 3.2, it is possible to create new project using the following wizards:

  • File - New - Kinetis SDK 1.x Project
  • File - New - Kinetis SDK 2.x Project

Both of them should be capable to create standalone projects.

Regards

Marek

Regards,
Marek
0 Kudos

10 Views
Contributor III

Hi Marek,

Ok. I will do that going forward. How do I fix what I have now so that I can get my external functions to work with main.c?

Thanks,

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos

10 Views
NXP Employee
NXP Employee

Hi Sara,

I'd recommend to create new project and move the modified sources into new project.

Regards

Marek

Regards,
Marek
0 Kudos

10 Views
Contributor III

Hi Marek,

Ok…so I created a standalone project and imported it into KDS. Nothing appears to be different though…still have virtual folders and no way to get them to recognize my functions.

Was I not supposed to import the project into KDS? If so, what was I supposed to do?

Sara

Sara Stout-Grandy, M.Eng., Ph.D., P.Eng.

Senior Hardware Designer

20 Angus Morton Dr., Bedford,

NS, Canada, B4B 0L9

902-450-1700, x278

0 Kudos