?? main.c
字號:
1cmd定義:
ramfuncs : LOAD = FLASHJ, PAGE = 0
RUN = RAMH0, PAGE = 0
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart)
secureRamFuncs : LOAD = FLASHP, PAGE = 0 /* Used by InitFlash() in SysCtrl.c */
RUN = RAMH0 , PAGE = 0
LOAD_START(_secureRamFuncs_loadstart),
LOAD_END(_secureRamFuncs_loadend),
RUN_START(_secureRamFuncs_runstart)
2定義變量(裝載或運行的起始地址)
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;
extern Uint16 secureRamFuncs_runstart;
extern Uint16 secureRamFuncs_loadstart;
extern Uint16 secureRamFuncs_loadend;
3把要拷貝到RAM里的函數(eva_timer1_isr,eva_timer2_isr...)定義到段ramfuncs
#pragma CODE_SECTION(eva_timer1_isr, "ramfuncs");
#pragma CODE_SECTION(eva_timer2_isr, "ramfuncs");
#pragma CODE_SECTION(evb_timer3_isr, "ramfuncs");
4把要初始化的flash控制寄存器函數定義到段secureRamFuncs
#pragma CODE_SECTION(InitFlash, "secureRamFuncs")
void InitFlash(void);
// 聲明中斷函數
interrupt void eva_timer1_isr(void);
interrupt void eva_timer2_isr(void);
interrupt void evb_timer3_isr(void);
interrupt void evb_timer4_isr(void);
//初始化flash 控制寄存器函數為
void InitFlash(void)
{
asm(" EALLOW"); // Enable EALLOW protected register access
FlashRegs.FPWR.bit.PWR = 3; // Pump and bank set to active mode
FlashRegs.FSTATUS.bit.V3STAT = 1; // Clear the 3VSTAT bit
FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF; // Sleep to standby transition cycles
FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF; // Standby to active transition cycles
FlashRegs.FBANKWAIT.bit.RANDWAIT = 5; // Random access waitstates
FlashRegs.FBANKWAIT.bit.PAGEWAIT = 5; // Paged access waitstates
FlashRegs.FOTPWAIT.bit.OPTWAIT = 5; // Random access waitstates
FlashRegs.FOPT.bit.ENPIPE = 1; // Enable the flash pipeline
asm(" EDIS"); // Disable EALLOW protected register access
/*** Force a complete pipeline flush to ensure that the write to the last register
configured occurs before returning. Safest thing is to wait 8 full cycles. ***/
asm(" RPT #7 || NOP");
}
//復制中斷向量到ram的函數為
void InitPieVectTable(void)
{
int16 i;
Uint32 *Source = (void *) &ieVectTableInit;
Uint32 *Dest = (void *) &ieVectTable;
EALLOW;
for(i=0; i < 128; i++)
*Dest++ = *Source++;
EDIS;
// Enable the PIE Vector Table
PieCtrl.PIECRTL.bit.ENPIE = 1;
}
4.在主函數中執行調用以下函數
/*初始化PIE矢量表*/
InitPieVectTable();
memcpy( &secureRamFuncs_runstart,
&secureRamFuncs_loadstart,
&secureRamFuncs_loadend - &secureRamFuncs_loadstart);
InitFlash();
memcpy( &RamfuncsRunStart,
&RamfuncsLoadStart,
&RamfuncsLoadEnd - &RamfuncsLoadStart);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -