
2、其次,编写程序,写入头函数。
3、然后,写一个延时函数,来调节流水灯的时间间隔。
4、最后,就是主函数,包括流水灯的反复循环和j流廊仗材水灯的方向。
1、要在Memory Section Manager属性中为“Segment For DSP/BIOS Objects” 和 “Segment For malloc()/free()”分配Dynamic Memory Heaps,必须首先在要分配的段(比如,IRAM)中勾选“create a heap in this memory“,并给出heaps size。2、要把*.tcf文件生成的*.cmd文件手动加入工程中,否则编译报错如下:
------------------------------ test.pjt - Debug ------------------------------
Warning: The project has no cmd file while the Text Linker is selected
[Linking...] "D:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -@"Debug.lkf"
<Linking>
>>warning: creating output section .gblinit without SECTIONS specification
>>warning: creating output section .mem without SECTIONS specification
>>warning: creating output section .rtdx_data without SECTIONS specification
>>warning: creating output section .sys without SECTIONS specification
>>warning: creating output section .clk without SECTIONS specification
>>warning: creating output section .hst1 without SECTIONS specification
>>warning: creating output section .hst without SECTIONS specification
>>warning: creating output section .pip without SECTIONS specification
>>warning: creating output section .hst0 without SECTIONS specification
>>warning: creating output section .hwi_vec without SECTIONS specification
>>warning: creating output section .swi without SECTIONS specification
>>warning: creating output section .printf without SECTIONS specification
>>warning: creating output section .sts without SECTIONS specification
>>warning: creating output section .tsk without SECTIONS specification
>>warning: creating output section .TSK_idle$stk without SECTIONS specification
>>warning: creating output section .idlcal without SECTIONS specification
>>warning: creating output section .idl without SECTIONS specification
>>warning: creating output section .LOG_system$buf without SECTIONS
specification
>>warning: creating output section .log without SECTIONS specification
>>warning: creating output section .sysinit without SECTIONS specification
>>warning: creating output section .vers without SECTIONS specification
>>warning: entry point symbol _c_int00 undefined
undefinedfirst referenced
symbol in file
-------------------------
SWI_D_rdytab d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IRAM$B d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_EXC_initd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_GBL_procId d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
__HOOK_knlId d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_KNL_exitd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IRAM$L d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
TSK_VCREATEFXN d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_UTL_doError d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
PIP_F_start d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
GBL_boot d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
TSK_VDELETEFXN d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
KNL_glue d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_UTL_doAbort d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IDL_F_loop d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_DFLTMICROSECS d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_GBL_cacheInit64Pd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_EXC_dispatchd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_htimePerLtime d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
GBL_stackbeg d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_D_tddr d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_UTL_doPutc d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_MEM d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
PRD_F_tick d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
__HOOK_NUMHOOKS d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_D_microseconds d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
RTA_F_or d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
TRC_R_mask d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
GBL_stackend d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_c_int00 d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK_config d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_OBJ_table d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
HWI_A_VECS d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_FXN_F_nop d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_enableTimer d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_D_prd d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IDL_D_calibrate d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_KNL_run d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
LNK_dspFrameRequestMask d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
CLK_F_isrd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
PIP_D_tabbeg d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
TRC_cinitd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_UTL_haltd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_MEM_initd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
RTA_F_dispatch d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK_startup d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK_setup d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_KNL_queues d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
CLK_A_TABBEG d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
LNK_F_dataPump d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
TSK_VEXITFXN d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
HWI_F_dispatch d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_RTDX_Poll d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK_initd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IDL_D_busyObjd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_TSK_exitd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
SWI_F_enable d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
FXN_F_rund:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_GBL_getVersion d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_CLK_inputClock d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
GBL_initdone d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
_HWI_dispatchTab d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
LNK_dspFrameReadyMaskd:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
IDL_F_busy d:\\CCStudio_v3.3\\myprojects\\test\\Debug\\testcfg.obj
>> error: symbol referencing errors - './Debug/test.out' not built
>>Compilation failure
Build Complete,
2 Errors, 23 Warnings, 0 Remarks.
3、
[main.c] "D:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -g -pdsw225 -fr"D:/CCStudio_v3.3/MyProjects/test/Debug" -d"_DEBUG" -me -mv6400+ -@"Debug.lkf" "main.c"
"main.c", line 20: warning: function declared implicitly
[Linking...] "D:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -@"Debug.lkf"
<Linking>
Build Complete,
0 Errors, 1 Warnings, 0 Remarks.
warning 的原因是对应行的元素没有声明。
解决办法就是加入声明。
举例如下:
#include <std.h>
#include <string.h>
//#include <stdio.h> //打开该句就可以了
void main(void)
{
unsigned int i
unsigned int sum=0
for(i = 0i<=100i++ )
{
sum += i
}
printf("the sum = %d .\n",sum)
printf("the program run over!\n")
printf("the program run over!\n")
我用的是28XX系列的,不知道经验对你有没有用,因为不同系列的芯片多少有些差别。TI提供的库已经相当可以了,兼顾易用与效率。我当时做过这样的测试
1. 用IQMATH实现
2. 直接C语言实现
3. C语言优化实现
4. 原生汇编实现
IQMATH的运行周期在1000左右,比方案3快几十个周期,比方案4慢几个周期,方案2是10000多个周期。
另外,因为只是单独测的算法,汇编之所以快是快在寄存器的使用上, *** 作数可以直接入寄存器,但是考虑到程序其他部分是用C语言编写的话,把 *** 作栈的时间也加上,并不比方案1快。毕竟我对TI的汇编吃的也不透。
在编写上,无疑是方案1提供了最接近C语言风格的实现,几乎不用考虑ISA方面的问题。
另外对于执行效率,我觉得主要考虑三点:
1.分支的使用
CCS对C语言的优化我没做过太多比对。其实单从反汇编的结果看,我接触过的嵌入式开发环境的编译器都能做出很好的优化。但是几乎每个编译器都会在逻辑的优化上有欠缺——它只能对一些显而易见的判断条件进行优化,而在写程序的过程中,我们经常出于易读性的考虑,或者稳定性的考虑,或者其他的考虑加入几乎不会发生的分支,这样的分支判断会消耗一定比率的代码段执行效率,视乎代码段内有用功能的长度而定,越长这个比率越小,越短这个比率越高。
2.一般 *** 作,就是各种赋值 *** 作
在一般的 *** 作上,编译器的优化已经很令人满意了,基本上可以作为编写汇编的范本。我觉得所谓效率能达到90%就是针对这个部分说的。
3.特殊 *** 作,比如对整块内存的 *** 作,或者是浮点运算上。
在一些特殊的 *** 作上,就要看是否有现成的库,或者看硬件是否支持。比如对整块内存 *** 作就别用循环一个字节一个字节的搬了。
以上三点都能考虑到的话,相信执行效率方面已经没有太大的提升空间了。
另外如果你的代码发生在初始化部分,也就是只在系统运行开始的时候运行一次,那么优化不优化其实没有太大的必要,除非你对系统初始化的时间有严格的要求。但是如果你的代码是作为任务要被反复运行的,那就有优化的必要了。
在CCS里有代码消耗时钟周期的统计,如果你觉得某段代码效率低下的话,可以先分段进行消耗时钟周期的计算,这样优化比较有针对性。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)