本篇主要说明如何在CCS3.3 对TI 6713 在 simulator中编写helloworld与LED设置。
simulator中编写helloworld,可以先参考下面的文章:
对于6713而言,与上面这篇文章有一些差异,大致流程如下:
1. 通过SetupCCStudiov3.3进行配置时,要选择6713 simulator,最重要的是在Processer属性中要设置Detect Reserved Memory Access为No;否则运行时,simulator中访问GPIO或者硬件地址时会报错。
2. 创建hello.c并导入到project,和上面文章中一样。
3. 添加rts6700.lib(大端为rts6700e.lib)到project中,库的路径为CCStudio_v3.3PLA\C6000\cgtools\lib,作用是这个库定义了_c_int00入口。
如果使用汇编语言编程,可以不用包括rts.lib库,入口地址及其标号可以由人工指定。而使用c时,就不同了,必须从rts.lib定义的这个入口_c_int00入口,是约定的。
4. 添加c6713.cmd文件,6713的cmd文件,IT官方的例子就可以,如下:
/****************************************************************************/
/* C6713.cmd */
/* Copyright (c) 2010 Texas Instruments Incorporated */
/* */
/* Description: This file is a sample linker command file that can be */
/* used for linking programs built with the C compiler and */
/* running the resulting .out file on an TMS320C6713 */
/* device. Use it as a guideline. You will want to */
/* change the memory layout to match your specific C6xxx */
/* target system. You may want to change the allocation */
/* scheme according to the size of your program. */
/* */
/****************************************************************************/
-stack 0x2000
-heap 0x8000
MEMORY
{
IRAM o = 0x00000000 l = 0x00030000 /* 192kB - Internal RAM */
L2RAM o = 0x00030000 l = 0x00010000 /* 64kB - Internal RAM/CACHE */
EMIFCE0 o = 0x80000000 l = 0x10000000 /* SDRAM in 6713 DSK */
EMIFCE1 o = 0x90000000 l = 0x10000000 /* Flash/CPLD in 6713 DSK */
EMIFCE2 o = 0xA0000000 l = 0x10000000 /* Daughterboard in 6713 DSK */
EMIFCE3 o = 0xB0000000 l = 0x10000000 /* Daughterboard in 6713 DSK */
}
SECTIONS
{
.text > IRAM
.stack > IRAM
.bss > IRAM
.cio > IRAM
.const > IRAM
.data > IRAM
.switch > IRAM
.sysmem > IRAM
.far > IRAM
.args > IRAM
.ppinfo > IRAM
.ppdata > IRAM
/* COFF sections */
.pinit > IRAM
.cinit > IRAM
/* EABI sections */
.binit > IRAM
.init_array > IRAM
.neardata > IRAM
.fardata > IRAM
.rodata > IRAM
.c6xabi.exidx > IRAM
.c6xabi.extab > IRAM
}
.cmd文件的主要作用是进行内存配置,告诉连接器如何对段进行内存映射;
.cmd文件其实也不是必须的,这里如果不添加.cmd文件,会按照处理器默认的方式进行内存分配和映射。
5. 编译并装载、运行,程序正常运行,但是看不到printf的打印,Stdout窗口调不出来;网上查了很多资料,没找到原因。
6. 设置LED相关GPIO,参考了下面的文章:
DSP(TMS320C6713)入门教程 - TI微控制器&处理器论坛 - 德州仪器TI单片机DSP官方技术论坛 - 21ic电子技术开发论坛https://bbs.21ic.com/icview-749150-1-1.html改写hello.c,代码如下:
#include <stdio.h>
void delay(unsigned int i) {
while(i--);
}
int main() {
*(unsigned int *)0x01B00000|=1<<13;
*(unsigned int *)0x01B00004|=1<<13;
while(1) {
*(unsigned int *)0x01B00008&=~(1<<13);
delay(0xffff);
*(unsigned int *)0x01B00008|=1<<13;
delay(0xffff);
}
//puts("helloworld\n");
//fflush(stdout);
//return 0;
}
Run过程中,按下Halt,发现代码停在delay()函数中,如下:
寄存器设置是瞬间的事情,程序绝大多数时间都处在while循环中。
打开Watch Window, 观察变量i的值如下: