飞思卡尔处理器K60学习笔记(三)---------DSP扩展的使用(CMSIS库的应用)

本文详细介绍了如何安装和使用CMSIS库,包括CMSIS库的准备工作、安装过程、项目创建、链接设置等步骤,提供了实用的参考教程,帮助后来者快速上手。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

很意外,由于系统原因,Codewarrior103.的软件被卸载了,估计将来很长的时间内都不会在用Codewarrior做开发。所以也就不再安装它了,具体内容也就只能转载别人的,不做详细使用指导了。

但本章节的内容,个人认为还是很重要的,就做下简单的记录,提供几个参考教程。方便后来人学习使用。

准备工作:1、有一个CMSIS库,个人认为还是下一个最新的吧。ARM官方网站可以下到(需要注册一个账号,免费)点击进入下载界面

参考1http://mcuoneclipse.com/2013/02/14/tutorial-using-the-arm-cmsis-library/,这篇文章写得很详细,可以就是图片全挂了,但还是有一定指导作用的。

为了方便本人将全文COPY下来作为备份

Installing CMSIS

To simplify things, I have the CMSIS zip file unpacked inside my workspace. It creates the folders ‘Device’, ‘CMSIS’ and a file with the version number:

Creating a Project

Inside the workspace, I create a project for my board using the File > New > Barboard Project wizard to create a GNU gcc project. This creates a default project for me:

Instead of writing my own example, I’m using one which is part of the CMSIS installation:sin cos example

:idea: ARM provides many such examples. They are a great way to verify that they work properly in my application. One consideration with using the libraries is their stack consumption. If they work as the simple example, but not within my application, then typically I have not reserved enough stack space. At least worth a try.

An easy way to add this file to my project is to drag&drop it into my project Sources folder. As the example comes with a main(), I can remove the original main.c from my project:


Added Sin Cos Example

Creating a Build Variable

We need to reference the CMSIS installation path in the next steps several times. To make things easier and more portable, I’m going to add a Build variable. For this I press ‘Add’ in the project properties > C/C++ Build > Build Variables:

Adding a Build Variable

In the following dialog I define my variable and press OK:

CMSIS_LOC Variable

:!: Of course you should use a path pointing to to where you have CMSIS installed. For me, it is is “c:\tmp\wsp_cmsis\CMSIS” in this tutorial, so you need to use the path which you have on your system.

With this, I can always use

${CMSIS_LOC}

instead of a hard-coded path.

Defined Build Variable

Using CMSIS

The above project will not compile and link. I need to tell the compiler where to are the CMSIS header files, and what library to link.

Header File Include

The CMSIS header files are in CMSIS\Include, so I add this to my compiler include paths:

Compiler Directories Setting

:idea: I’m using here the CMSIS library inside my workspace. Change the path if you have the CMSIS installed somewhere else.

Architecture Define

The other important thing is: I need to set a define which tells the CMSIS library which ARM Cortex core I’m using. For the ARM Cortex-M0+ this isARM_MATH_CM0. I add this define to the project properties of the ARM gcc preprocessor settings.

Added ARM_MATH_CM0 to the Preprocessor Defined Symbols

:idea: If using an ARM Cortex-M4 (like for the Kinetis K family), then the define would beARM_MATH_CM4

Library

CMSIS already comes with pre-built libraries. So all what I need to do for gcc is to link the correct libraries with my application. The libraries are inside CMSIS\Lib\GCC:

GCC CMSIS libraries

:idea: The M denotes the ARM core, while the ‘l’ means ‘little endian’. The ‘f’ means an ARM core with Harware Floating Point Unit (e.g. Cortex-M4F).

With this information, I add the library name and the library search path to my linker settings:

Linker Library Settings

:!: Important: the library name is *without* the ‘lib’ prefix and *without* the ‘.a’ suffix! SeeCreating and using Libraries with ARM gcc and Eclipse.

Build and Debug

With this, everything should be in place to compile, link and download without errors. But if I step into the CMSIS functions, I get a message from the debugger that it cannot find the source file:

Can’t finda source file

The reason is that I’m using the precompiled libraries from ARM, and obviously that person was using a different path to the CMSIS library.

To help the debugger to find the source, I’m going to add a path mapping. I press the ‘Edit Source Lookup Path’ button:

Edit Source Lookup Path

Then I select Path Mapping:

Add a container to the source lookup path

Then I specify that ‘c:\working\CMSIS_Setup\CMSIS shall be replace with the path on my machine:

Specified Path Mapping

:?: I would love to use my ${CMSIS_LOC} variable in that dialog, but this is not supported in this Eclipse version? That would be a great feature extension.

Now it shows the source properly:

Showing CMSIS Source

参考2: http://blog.sina.com.cn/s/blog_9ca04b1901014tdo.html

1. Install “KINETIS_SMSIS_2.10”. Install CW10.2 Update1.0.0.

2. Unzipped the attached zip file.

3. Copy “CWCC” folder to “KINETIS_CMSIS_2.10\Examples\”folder.

4. Replace the existed “core_cm4.h” file, which islocated  in the “KINETIS_CMSIS_2.10\CMSIS\Include”folder, with the attached “core_cm4.h” file.

5. Copy “twrk60n512_blinky” folder to“KINETIS_CMSIS_2.10\Examples\twrk60n512_blinky” folder, and renamethe folder name from “twrk60n512_blinky” to “CodeWarrior”.

6. Copy “twrk40x256_blinky” folder to“KINETIS_CMSIS_2.10\Examples\twrk40x256_blinky” folder, and renamethe folder name from “twrk40x256_blinky” to “CodeWarrior”.

7. Create a empty folder named “CodeWarrior” in“KINETIS_CMSIS_2.10\Examples\sin_cos_example” folder.

8. Copy “twrk40x256_sin_cos_example” folder and“twrk60n512_sin_cos_example”  folder to the“KINETIS_CMSIS_2.10\Examples\sin_cos_example\CodeWarrior”folder.

9. Rename the “twrk40x256_sin_cos_example” folder to“twrk40x256”.

10. Rename the “twrk60n512_sin_cos_example” folder to“twrk60n512”.

参考3:http://www.freescaleic.org/bbs/article_891_299345.html

按照野火团队,官方CMISI的库有问题,存在BUG,然后他们做了修改。版本是2.1的。现在最新的是3.1的好像。大家可以看看,并且,野火提供了完整的M4的底层库,想玩的可以好好利用下。


说句真心的,飞思卡尔的底层支持真心给跪。推荐还是用MDK或者IAR,还有官方库(CMSIS)支持。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值