/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: target.c
** Last modified Date: 2004-09-17
** Last Version: 1.0
** Descriptions: header file of the specific codes for LPC2100 target boards
** Every project should include a copy of this file, user may modify it as needed
**------------------------------------------------------------------------------------------------------
** Created by: Chenmingji
** Created date: 2004-02-02
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by: Chenmingji
** Modified date: 2004-09-17
** Version: 1.01
** Descriptions: Renewed the template, added more compiler supports
**
**------------------------------------------------------------------------------------------------------
**Modified by: LinEnqiang
** Modified date: 2007/05/26
** Version: 1.02
** Descriptions: Modified for NXP23XX
**
********************************************************************************************************/
#define IN_TARGET
#include "config.h"
/*********************************************************************************************************
** Function name: FIQ_Exception
**
** Descriptions: Fast interrupt exceptional handler , change it as needed
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Chenmingji
** Created Date: 2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void FIQ_Exception(void)
{
// while(1); // change it to your code 这一句替换为自己的代码
}
/*********************************************************************************************************
** Function name: TargetInit
**
** Descriptions: Initialize the target board; it is called in a necessary place, change it as
** needed
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Chenmingji
** Created Date: 2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetInit(void)
{
/* 添加自己的代码 */
/* Add your codes here */
}
/*********************************************************************************************************
** Function name: TargetResetInit
**
** Descriptions: Initialize the target
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Chenmingji
** Created Date: 2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by: LinEnqiang
** Modified date: 2007/05/26
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void TargetResetInit(void)
{
#ifdef __DEBUG_RAM
MEMMAP = 0x2; // remap
#endif
#ifdef __DEBUG_FLASH
MEMMAP = 0x1; // remap
#endif
#ifdef __IN_CHIP
MEMMAP = 0x1; // remap
#endif
if ( PLLSTAT & (1 << 25) )
{
PLLCON = 1; // Enable PLL, disconnected
PLLFEED = 0xAA;
PLLFEED = 0x55;
}
PLLCON = 0; //Disable PLL, disconnected
PLLFEED = 0xAA;
PLLFEED = 0x55;
while(PLLSTAT & (3 << 24));
SCS = (SCS & 0x04)|0x20; // Enable the main OSC,,1MHz~20MHz
while((SCS & 0x40) == 0 ); // Wait until main OSC is usable
CLKSRCSEL = 0x01; // select main OSC as the PLL clock source
PLLCFG = (((PLL_NValue) << 16)|(PLL_MValue));
PLLCON = 1;
PLLFEED = 0xAA; // Enable but disconnect the PLL
PLLFEED = 0x55;
while (((PLLSTAT & (1 << 24)) == 0)); // Wait until the PLL is usable
CCLKCFG = CCLKDivValue;
#if USE_USB
USBCLKCFG = USBCLKDivValue; // usbclk = 288 MHz/6 = 48 MHz
PCONP |= 0x80000000; // Turn On USB PCLK
#else
USBCLKCFG = USBCLKDivValue;
PCONP &= 0x7FFFFFFF;
#endif
while ( ((PLLSTAT & (1 << 26)) == 0) ); // Check lock bit status
while (((PLLSTAT & 0x00007FFF) != PLL_MValue) && (((PLLSTAT & 0x00FF0000) >> 16) != PLL_NValue));
PLLCON = 3; // connect the PLL
PLLFEED = 0xAA;
PLLFEED = 0x55;
while (((PLLSTAT & (1 << 25))!= (1 << 25)));// Wait until the PLL is connected and locked
// Set system timers for each component
#if (Fpclk / (Fcclk / 4)) == 1
PCLKSEL0 = 0x00000000; // PCLK is 1/4 CCLK
PCLKSEL1 = 0x00000000;
#else
#if (Fpclk / (Fcclk / 4)) == 2
PCLKSEL0 = 0xAAAAAAAA; // PCLK is 1/2 CCLK
PCLKSEL1 = 0xAAAAAAAA;
#else
PCLKSEL0 = 0x55555555; // PCLK is the same as CCLK
PCLKSEL1 = 0x55555555;
#endif
#endif
/* Set memory accelerater module*/
MAMCR = 0;
#if Fcclk < 20000000
MAMTIM = 1;
#else
#if Fcclk < 40000000
MAMTIM = 2;
#else
MAMTIM = 3;
#endif
#endif
MAMCR = 2;
/* Add your codes here */
return;
}
/*********************************************************************************************************
** 以下为一些与系统相关的库函数的实现
** 具体作用请ads的参考编译器与库函数手册
** 用户可以根据自己的要求修改
********************************************************************************************************/
/*********************************************************************************************************
** 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 =l
GPIO.rar_LPC23XX GPIO
版权申诉
59 浏览量
2022-09-23
09:57:54
上传
评论
收藏 183KB RAR 举报
钱亚锋
- 粉丝: 86
- 资源: 1万+
最新资源
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- sdk.config
- 基于matlab实现配电网三相潮流计算方法,对几种常用的配电网潮流计算方法进行了对比分析.rar
- 基于matlab实现配电网潮流 经典33节点 前推回代法潮流计算 回代电流 前推电压 带注释.rar
- 基于matlab实现模拟退火遗传算法的车辆调度问题研究,用MATLAB语言加以实现.rar
- 基于matlab实现蒙特卡洛的的移动传感器节点定位算法仿真代码.rar
- 华中数控系统818用户说明书
- 基于matlab实现卡尔曼滤波器完成多传感器数据融合 对多个机器人的不同传感器数据进行融合估计足球精确位置.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈