📄 target.c
字号:
/*****************************************************************************/
/* target.c: Philips LPC214x家族微控制器初始化片内外设的C文件 */
/* 作者:焦进星 */
/* 时间:2008年月1月22日 */
/* ARM初学 */
/*****************************************************************************/
#include "target.h"
/******************************************************************************
** Function name: TargetInit
**
** Descriptions: Initialize the target board; it is called in a necessary
** place, change it as needed
**
** parameters: None
** Returned value: None
**
******************************************************************************/
void TargetInit(void)
{
/* 增加你自己的代码 */
}
/******************************************************************************
** Function name: TargetResetInit
**
** Descriptions: Initialize the target board before running the main()
** function; User may change it as needed, but may not
** deleted it.
**
** parameters: None
** Returned value: None
**
******************************************************************************/
#define PLLE 0
#define PLLC 1
#define PLOCK 10
void TargetResetInit(void)
{
/* 设置存储器映射 */
#ifdef __DEBUG_RAM
MEMMAP = 0x2; /* 用户RAM模式 */
#endif
#ifdef __DEBUG_FLASH
MEMMAP = 0x1; /* 用户FLASH模式 */
#endif
#ifdef __IN_CHIP
MEMMAP = 0x1; /* 用户FLASH模式 */
#endif
/* 设置VPB分频器 */
#if (Fpclk / (Fcclk / 4)) == 1
VPBDIV = 0;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
VPBDIV = 2;
#endif
#if (Fpclk / (Fcclk / 4)) == 4
VPBDIV = 1;
#endif
/* 设置PLL倍频值 */
PLLCON = 0 ;
PLLCON = 1 << PLLE ; /* PLL使能 */
#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 = 0x55;
while((PLLSTAT & (1 << PLOCK)) == 0); /* 等待PLL上锁 */
PLLCON |= 1 << PLLE | 1 << PLLC; /* PLL使能并连接 */
PLLFEED = 0xaa; /* 馈送 */
PLLFEED = 0x55;
/* 设置内存加速模块 */
MAMCR = 0;
/* 设置MAM取指周期 */
#if Fcclk < 20000000 /* 20M以下 */
MAMTIM = 1;
#else
#if Fcclk < 40000000 /* 20M-40M */
MAMTIM = 2;
#else
MAMTIM = 3; /* 40M以上 */
#endif
#endif
/* 设置MAM模式 */
MAMCR = 2; /* MAM完全使能 */
TargetInit(); /* 用户自己的初始化代码 */
init_VIC(); /* 初始化中断系统 */
}
/******************************************************************************
** End Of File
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -