使用Code Composer Studio Version: 10.1.0.00010 ,建立TMS320F28335工程。
/* * main.c */ #include <stdio.h> int fputc(int ch, FILE *f) { while(ScibRegs.SCICTL2.bit.TXRDY == 0); ScibRegs.SCITXBUF=ch;
return ch; } int main(void) { printf("Hello DSP!\r\n"); return 0; }
编译出错
"../CMD/F28335.cmd", line 66: error: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. run placement with alignment/blocking fails for section ".stack" size 0x400page 1. Available memory ranges: RAMM1 size: 0x400 unused: 0x0 max hole: 0x0
查看F28335.cmd文件
PAGE 1 : /* Data Memory */ /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */ /* Registers remain on PAGE1 */ BOOT_RSVD : origin = 0x000000, length = 0x000050 /* Part of M0, BOOT rom will use this for stack */ RAMM0 : origin = 0x000050, length = 0x0003B0 /* on-chip RAM block M0 */ RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */ RAML4 : origin = 0x00C000, length = 0x001000 /* on-chip RAM block L1 */ RAML5 : origin = 0x00D000, length = 0x001000 /* on-chip RAM block L1 */ RAML6 : origin = 0x00E000, length = 0x001000 /* on-chip RAM block L1 */ RAML7 : origin = 0x00F000, length = 0x001000 /* on-chip RAM block L1 */
PAGE1 为数据存储区
/* Allocate uninitalized data sections: */ .stack : > RAMM1 PAGE = 1 .ebss : > RAML5 PAGE = 1 .esysmem : > RAMM1 PAGE = 1
stack段空间不够,修改为
/* Allocate uninitalized data sections: */ .stack : > RAML4 PAGE = 1 .ebss : > RAML5 PAGE = 1 .esysmem : > RAML4 PAGE = 1
修改Printf支持,Level of printf/scanf support required(--printf_support)选择minimal
堆栈设置
编译通过,可以正常使用printf函数。