?? target.c
字號(hào):
/******************************************************************************************************
** File name: target.c
** Descriptions: header file of the specific codes for LPC2200 target boards
** Every project should include a copy of this file, user may modify it as needed
********************************************************************************************************/
#define IN_TARGET
#include "config.h"
/*********************************************************************************************************
** Function name: IRQ_Exception
********************************************************************************************************/
void __irq IRQ_Exception(void)
{
while(1); // change it to your code 這一句替換為自己的代碼
}
/*********************************************************************************************************
** Function name: FIQ_Exception
********************************************************************************************************/
void FIQ_Exception(void)
{
while(1); // change it to your code 這一句替換為自己的代碼
}
/*********************************************************************************************************
** Function name: TargetInit
********************************************************************************************************/
void TargetInit(void)
{
/* 添加自己的代碼 */
/* Add your codes here */
}
/*********************************************************************************************************
** Function name: TargetResetInit
**
** Descriptions: 進(jìn)入之前的目標(biāo)板初始化,可以被修改,但不能被刪除
********************************************************************************************************/
void TargetResetInit(void)
{
/*設(shè)置存儲(chǔ)器映射方式*/
#ifdef __DEBUG
MEMMAP = 0x3; //remap,對(duì)0X00000008讀數(shù)/取指就是從片外0x80000000單元進(jìn)行操作
#endif
#ifdef __OUT_CHIP
MEMMAP = 0x3; //remap, 對(duì)0X00000008讀數(shù)/取指就是從片外0x80000000單元進(jìn)行操作
#endif
#ifdef __IN_CHIP
MEMMAP = 0x1; //remap, 對(duì)0X00000008讀數(shù)/取指就是從片外0x00000000單元進(jìn)行操作
#endif
/* 設(shè)置系統(tǒng)各部分時(shí)鐘,由系統(tǒng)硬件決定*/
/* 設(shè)置外設(shè)時(shí)鐘(pclk)與系統(tǒng)時(shí)鐘(cclk)分頻比*/
/* Set system timers for each component,其中cclk=M*Fosc,cclk=Fcco/(2*P),M、P分別是PLLCFG的低5位,高2位*/
PLLCON = 1; //設(shè)置激活但未連接PLL
#if (Fpclk / (Fcclk / 4)) == 1 //此值由系統(tǒng)硬件決定
VPBDIV = 0;
#endif
#if (Fpclk / (Fcclk / 4)) == 2 //此值由系統(tǒng)硬件決定
VPBDIV = 2;
#endif
#if (Fpclk / (Fcclk / 4)) == 4 //此值由系統(tǒng)硬件決定
VPBDIV = 1;
#endif
/*設(shè)定PLL的乘因子M和除因子P的值*/
#if (Fcco / Fcclk) == 2
PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
PLLFEED = 0xaa; /*必須將正確的饋送序列寫入PLLFEED,才能使PLLCON 和 PLLCFG更改生效*/
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0); /*判斷PLLSTAT的PLOCK位是否為0,是,則表明PLL為鎖定,否,則表明PLL鎖定到指定頻率*/
PLLCON = 3;
PLLFEED = 0xaa; /*發(fā)送PLL饋送序列,執(zhí)行激活和連接動(dòng)作*/
PLLFEED = 0x55;
/* 設(shè)置存儲(chǔ)器加速模塊 */
/* Set memory accelerater module,由于LPC2210沒有片內(nèi)FLASH,MAM設(shè)置無效*/
MAMCR = 0; /*禁止MAM功能*/
#if Fcclk < 20000000 /*系統(tǒng)時(shí)鐘低于20MHZ,建議設(shè)置為1 */
MAMTIM = 1; /*當(dāng)改變MAM定時(shí)值時(shí),必須先通過向MAMCR寫入0關(guān)閉MAM,然后將新值寫入MAMTIM。最后將需要的操作模式
的對(duì)應(yīng)值(1或2)寫入MAMCR,再次打開MAM。*/
#else
#if Fcclk < 40000000 /*系統(tǒng)時(shí)鐘在20~40MHZ之間,建議設(shè)置為2 */
MAMTIM = 2;
#else /*系統(tǒng)時(shí)鐘高于40MHZ,建議設(shè)置為3 */
MAMTIM = 3;
#endif
#endif
MAMCR = 2; /*使能MAM*/
/* 初始化VIC */
/* initialize VIC*/
VICIntEnClr = 0xffffffff; /*寫1清零VICIntEnable中斷使能寄存器中的對(duì)應(yīng)位并禁止對(duì)應(yīng)的中斷請(qǐng)求*/
VICVectAddr = 0; /*寫0將清零內(nèi)部中斷優(yōu)先級(jí)硬件當(dāng)中對(duì)應(yīng)的標(biāo)志*/
VICIntSelect = 0; /*寫0,對(duì)應(yīng)的中斷請(qǐng)求分配為IRQ*/
/* 添加自己的代碼 */
/* Add your codes here */
}
/*********************************************************************************************************
** 以下為一些與系統(tǒng)相關(guān)的庫函數(shù)的實(shí)現(xiàn)
** 具體作用請(qǐng)參考ads的編譯器與庫函數(shù)手冊(cè)
** 用戶可以根據(jù)自己的要求修改
********************************************************************************************************/
/*********************************************************************************************************
** The implementations for some library functions
** For more details, please refer to the ADS compiler handbook and The library
** function manual
** User could change it as needed
********************************************************************************************************/
#include "rt_sys.h"
#include "stdio.h"
#pragma import(__use_no_semihosting_swi)
#pragma import(__use_two_region_memory)
int __rt_div0(int a)
{
a = a;
return 0;
}
int fputc(int ch,FILE *f)
{
ch = ch;
f = f;
return 0;
}
int fgetc(FILE *f)
{
f = f;
return 0;
}
int _sys_close(FILEHANDLE fh)
{
fh = fh;
return 0;
}
int _sys_write(FILEHANDLE fh, const unsigned char * buf,
unsigned len, int mode)
{
fh = fh;
buf = buf;
len =len;
mode = mode;
return 0;
}
int _sys_read(FILEHANDLE fh, unsigned char * buf,
unsigned len, int mode)
{
fh = fh;
buf = buf;
len =len;
mode = mode;
return 0;
}
void _ttywrch(int ch)
{
ch = ch;
}
int _sys_istty(FILEHANDLE fh)
{
fh = fh;
return 0;
}
int _sys_seek(FILEHANDLE fh, long pos)
{
fh = fh;
return 0;
}
int _sys_ensure(FILEHANDLE fh)
{
fh = fh;
return 0;
}
long _sys_flen(FILEHANDLE fh)
{
fh = fh;
return 0;
}
int _sys_tmpnam(char * name, int sig, unsigned maxlen)
{
name = name;
sig = sig;
maxlen = maxlen;
return 0;
}
void _sys_exit(int returncode)
{
returncode = returncode;
}
char *_sys_command_string(char * cmd, int len)
{
cmd = cmd;
len = len;
return 0;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -