打印
[工具和软件]

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

[复制链接]
1678|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Vitality1|  楼主 | 2015-2-27 15:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
很意外,由于系统原因,Codewarrior103.的软件被卸载了,估计将来很长的时间内都不会在用Codewarrior做开发。所以也就不再安装它了,具体内容也就只能转载别人的,不做详细使用指导了。
但本章节的内容,个人认为还是很重要的,就做下简单的记录,提供几个参考教程。方便后来人学习使用。
准备工作:1、有一个CMSIS库,个人认为还是下一个最新的吧。ARM官方网站可以下到(需要注册一个账号,免费)点击进入下载界面。
参考1:http://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
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

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

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

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



相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

81

主题

421

帖子

9

粉丝