我是新手,好容易调通了一个程序,却写不到芯片里,总是出现如下报警: load failed. a section of your program falls into a memory region that is not writable.check your linker configuration an /memory map. 我的连接是没有问题的, memory map 可能也没问题!下面是相关的文件: 请高手给我指点指点,我卡在这里无法继续进行了!(还有一个问题就是我要写的芯片是别人写过程序的片子,不知道和这个有没有关系,如果有关系,请告诉我我怎么才能写进新程序!) 先谢谢大家! /********************************************************************/ /* Code Composer Studio supports five reserved GEL functions that */ /* automatically get executed if they are defined. They are: */ /* */ /* StartUp() - Executed whenever CCS is invoked */ /* OnReset() - Executed after Debug->Reset CPU */ /* OnRestart() - Executed after Debug->Restart */ /* OnPreFileLoaded() - Executed before File->Load Program */ /* OnFileLoaded() - Executed after File->Load Program */ /* */ /********************************************************************/ StartUp() { /* Initialize F2407 memory map */ F2407_Memory_Map(); } /* uncomment the function(s) you want Code Composer Studio to execute OnReset(int nErrorCode) { } OnRestart(int nErrorCode) { } OnPreFileLoaded() { } OnFileLoaded(int nErrorCode, int bSymbolsOnly) { } */ menuitem "Initialize Memory Map"; /*----------------------- F2407 Memory Map -------------------------*/ /* */ /* The entire LF2407 address space (program, data, IO) is mapped */ /* as RAM with two exceptions. The on-chip flash is mapped as */ /* ROM and the following illegal/reserved sections are not */ /* mapped: */ /* */ /* Illegal/Rsvd Program Illegal/Rsvd Data Illegal/Rsvd IO */ /* -------------------- ----------------- --------------- */ /* None 0x0080 - 0x01ff None */ /* 0x0400 - 0x07ff */ /* 0x1000 - 0x6fff */ /*------------------------------------------------------------------*/ hotmenu F2407_Memory_Map() { int SCSR2 =*0x7019; /* System Control and Status Register 2 */ GEL_MapReset(); GEL_MapOn();
/* Check MPNMC value (SCSR2 bit 2) to determine map setting. */ if(SCSR2 & 4) GEL_MapAdd(0x0000,0,0x8000,1,1); /* Ext prog memory */ else GEL_MapAdd(0x0000,0,0x8000,1,0); /* On-chip flash memory */ /* Program Memory Maps */ GEL_MapAdd(0x8000,0,0x0800,1,1); /* SARAM */ GEL_MapAdd(0x8800,0,0x7800,1,1); /* External RAM */ /* Data Memory Maps */ GEL_MapAdd(0x0000,1,0x0060,1,1); /* Mem mapped regs */ GEL_MapAdd(0x0060,1,0x0020,1,1); /* DARAM B2 */ GEL_MapAdd(0x0200,1,0x0200,1,1); /* DARAM B0 & B1 */ GEL_MapAdd(0x0800,1,0x0800,1,1); /* SARAM */ GEL_MapAdd(0x7000,1,0x1000,1,1); /* Peripherals */ GEL_MapAdd(0x8000,1,0x8000,1,1); /* External RAM */ /* I/O Memory Maps */ GEL_MapAdd(0x0000,2,0x10000,1,1); } menuitem "Watchdog"; hotmenu Disable_WD() { /* Enable WD override */ *0x7029 = *0x7029 | 0x0068; *0x7025 = 0x0055; *0x7025 = 0x00AA; } /**********************************************/
"vectors.asm" /**********************************************/ .title "vectors.asm" .ref _c_int0,_nothing .sect ".vectors" reset: B _c_int0 int1: b _nothing int2: b _nothing int3: b _nothing int4: b _nothing int5: b _nothing int6: b _nothing /**********************************************/ "roam.cmd" /**********************************************/ -stack 40 MEMORY { PAGE 0: VECS rigin=0x0000,length=0x0040 PVECS : origin = 0x0040 ,length = 0x0070 PROG : origin=0x00b0,length=0x7f50 PAGE 1: MMRSrigin = 0x0000, length = 0x005f B0 : origin=0x0200,length=0x0050 B1 : origin = 0x0300 , length = 100h /* DARAM B1 块 */ B2 : origin=0x0060,length=0x0020 SARAM : origin=0x0800,length=0x0700 EXT : origin=0x8000,length=0x8000 } SECTIONS { .reset :{} >VECS PAGE 0 .vectors : {}>VECS PAGE 0 .pvecs:{} >VECS PAGE 0 .text : {} >ROG PAGE 0 .cinit :{} >ROG PAGE 0 .const : {} > SARAM PAGE 1 .bss : {} > SARAM PAGE 1 .stack : {} > B1 PAGE 1 } /**********************************************/ "wgfiotest.c" /**********************************************/ #include "regs.h" initial() { asm(" setc SXM"); asm(" clrc OVM"); asm(" clrc CNF"); asm(" setc INTM"); *SCSR1 = 0x81FE; *WDCR = 0x0e8;
*IMR = 0x0000; *IFR = 0x0FFFF; *MCRA = *MCRA & 0x0FF;
*PBDATDIR = * PBDATDIR |0x0FF00; *MCRC = *MCRC & 0x0FBFF; *PBDATDIR = *PBDATDIR & 0x0FF00; *PFDATDIR = *PBDATDIR | 0x0404; *PFDATDIR = *PFDATDIR & 0x0FFFB; } main() { int led; int i,k; initial(); while(1) { for(led = 0x0080,i = 0;i < 8;led = led >>1,i++) { *PBDATDIR = * PBDATDIR & 0x0FF00; *PBDATDIR = *PBDATDIR | led; *PFDATDIR = *PBDATDIR | 0x0404; *PFDATDIR = *PFDATDIR & 0x0FFFB; for(k = 0;k<0x0fff;k++) k = k; } } } void interrupt nothing() { return; } /*****************************************************************************/ /* regs.H v3.07 */ /* Copyright (c) 1993-2003 Texas Instruments Incorporated */ /*****************************************************************************/
volatile unsigned int *SCSR1 = (volatile unsigned int *) 0x7018; volatile unsigned int *WDCR = (volatile unsigned int *) 0x7029; volatile unsigned int *IMR = (volatile unsigned int *) 0x0004; volatile unsigned int *IFR = (volatile unsigned int *) 0x0006; volatile unsigned int *MCRA = (volatile unsigned int *) 0x7090; volatile unsigned int *MCRC = (volatile unsigned int *) 0x7094; volatile unsigned int *PBDATDIR = (volatile unsigned int *) 0x7098; volatile unsigned int *PFDATDIR = (volatile unsigned int *) 0x7096; |