为C6713建立一个简单的工程

今天下载了CCS的最新版本5.4,建立了一个乘加的c工程。CCS5.4只需添加一个main.c就可以编译生成out文件了,很方便。

int main(void) {
	int a[]={1,2,3,4,5};
	int x[]={5,4,3,2,1};

	int i=0;
	int sum = 0;
	for(i = 0; i < 5; i++)
	{
		sum += a[i]*x[i];
	}
	
	;
	return 0;
}

 

好久不用CCS3.3,今天用它建立一个基于C6713的c工程,因为时间有点久了,居然费了不好周折。看来还是得总结出来,不然容易忘。

除了main.c,还需要cmd文件,asm文件和rts lib文件,否则会报错。

由此产生一个问题,_c_int00的作用是什么?(一下网上收集)

在DSP启动后,系统会进入复位中断,此时复位中断服务函数为c_init00,此函数用于建立C环境,为进入main()函数进行系统初始化,主要工作是建立堆栈,初始化全局变量等。

全局变量的初始化:如果程序在链接时采用-c选项,则编译链接后的可执行程序会将全局变量的初始化放在c_init00()函数中进行,在此函数中会调用_auto_init(CINIT)函数,将.cinit段的内容拷入.bss中相应的变量中,此过程是在系统上电后进入main()函数之前执行的。

如果程序在链接时采用-cr选项,则编译后的可执行程序中全局变量需要使用loader进行初始化,这种方法一般用于在JTAG调试时,CCS即为loader。

一下是c_int00的代码,来自rts.src

/*****************************************************************************/
/* C_INT00() - C ENVIRONMENT ENTRY POINT                                     */
/*****************************************************************************/
extern void __interrupt c_int00()
{

   /*------------------------------------------------------------------------*/
   /* SET UP THE STACK POINTER IN B15.                                       */
   /* THE STACK POINTER POINTS 1 WORD PAST THE TOP OF THE STACK, SO SUBTRACT */
   /* 1 WORD FROM THE SIZE. ALSO THE SP MUST BE ALIGNED ON AN 8-BYTE BOUNDARY*/
   /*------------------------------------------------------------------------*/
   __asm("\t   MVKL\t\t   __stack + __STACK_SIZE - 4, SP");
   __asm("\t   MVKH\t\t   __stack + __STACK_SIZE - 4, SP");
   __asm("\t   AND\t\t   ~7,SP,SP");               

   /*------------------------------------------------------------------------*/
   /* SET UP THE GLOBAL PAGE POINTER IN B14.                                 */
   /*------------------------------------------------------------------------*/
   __asm("\t   MVKL\t\t   $bss,DP");
   __asm("\t   MVKH\t\t   $bss,DP");

   /*------------------------------------------------------------------------*/
   /* SET UP FLOATING POINT REGISTERS FOR C6700                              */
   /*------------------------------------------------------------------------*/
#ifdef _TMS320C6700
   FADCR = 0; FMCR  = 0;
#endif

   /*------------------------------------------------------------------------*/
   /* CALL THE AUTOINITIALIZATION ROUTINE.                                   */
   /*------------------------------------------------------------------------*/
   _auto_init(CINIT);
   
   _args_main();

   /*------------------------------------------------------------------------*/
   /* CALL EXIT.                                                             */
   /*------------------------------------------------------------------------*/
   exit(1);
}


 

args_main.c/    1162235705  0     0     0       1930      `
/******************************************************************************/
/* The ARGS data structure is defined according to a convention with linker.  */
/*                                                                            */
/* If the user want to pass arguments to loader, "--args=###" option has to   */
/* be used in linking to generate executable. With this option, the linker    */
/* will allocate a section starting with __c_args__, and with this "###" many */
/* bytes. The loader when parses the arguments, will dump the number of       */
/* arguments, argc as the 1st arguments at address __c_args__, all the actual */
/* arguments will be dumped after that. The total space for these arguments   */
/* will not exceed "###" bytes.                                               */
/*                                                                            */
/* if "--args="###" is not used as a linker option, linker will put -1 at     */
/* __c_args__ location.                                                       */ 
/*                                                                            */
/* Based on the above convention, the following code implements the access to */
/* these arguments when main is called.                                       */
/*                                                                            */
/* This function is called from boot.asm or boot.c.                           */
/******************************************************************************/

typedef struct { int argc; char *argv[1]; } ARGS;
extern ARGS __c_args__;

extern far int main(int argc, char *argv[]);

int _args_main()
{
   register ARGS *pargs = &__c_args__;
   register int    argc = 0;
   register char **argv = 0;
   
   if (pargs != (ARGS *)-1) 
      { argc = pargs->argc; argv = pargs->argv; }
  
   return main(argc, argv);
}


 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
/********************************************************************************\ \* DEC6713_GPIO.c V1.00 *\ \* Copyright 2004 by SEED Electronic Technology LTD. *\ \* All rights reserved. SEED Electronic Technology LTD. *\ \* Restricted rights to use, duplicate or disclose this code are *\ \* granted through contract. *\ \* Designed by: Hongshuai.Li *\ \********************************************************************************/ /********************************************************************************\ \* The example introduces using technique for GPIO. It generates a certain frequency pulse on pin GPIO X. LED D8 will twinkle,if the routine runs correctly.*\ \********************************************************************************/ #include #include #include /********************************************************************************/ static GPIO_Handle hGpio; extern far void vectors(); /********************************************************************************/ /********************************************************************************/ main() { /* Initialize CSL,must when using CSL. */ CSL_init(); /* Initialize DEC6713 board. */ DEC6713_init(); IRQ_setVecs(vectors); /* point to the IRQ vector table */ IRQ_globalEnable(); /* Globally enable interrupts */ IRQ_nmiEnable(); /* Enable NMI interrupt */ /* Set GPIO. */ hGpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET); GPIO_reset(hGpio); //GPIO_config(hGpio,&MyGPIOCfg); GPIO_pinEnable(hGpio,GPIO_PIN13); GPIO_pinDirection(hGpio,GPIO_PIN13,GPIO_OUTPUT); while(1) { GPIO_pinWrite(hGpio,GPIO_PIN13,0); DEC6713_wait(0xfffff); GPIO_pinWrite(hGpio,GPIO_PIN13,1); DEC6713_wait(0xfffff); } } /***************************
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值