⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 这是LPC2300的例程 ZLG的ARM2300开发板带的
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:			lizhongsheng
** Modified date:		2006-3-15
** Version:				
** Descriptions:		PLL PowerDown and wake up
**
********************************************************************************************************/
#include 	"config.h"

#define 	EINT0			0x00000001	  		//中断标志0位	

void PLLinit(void)
{
	SCS = (SCS & 0x04)|0x20;                // Enable the main OSC,,1MHz~20MHz       							      
    while((SCS & 0x40) == 0 );			    // Wait until main OSC is usable 
 
	if ( PLLSTAT & (1 << 25) )				// if the PLL was connected
    {
		PLLCON  = 0x01;										
		PLLFEED = 0xAA;						// disconnect the PLL
		PLLFEED = 0x55;	
		PLLCON  = 0x00;										
		PLLFEED = 0xAA;						// disable the PLL
		PLLFEED = 0x55;			
    }  
	else if ( PLLSTAT & (1 << 24) )			// if the PLL was enabled 		                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // 如果PLL已被使能,则先禁止PLL
    {
		PLLCON  = 0x00;										
		PLLFEED = 0xAA;						// disable the PLL
		PLLFEED = 0x55;
    }
        
    CLKSRCSEL = 0x01;						// select main OSC as the PLL clock source 
	PLLCON = 1;								// Enable but disconnect the PLL
    PLLCFG  = (((PLL_NValue-1) << 16)|(PLL_MValue-1) );  	// set the PLLCFG		
    PLLFEED = 0xAA;							// Enable PLL
    PLLFEED = 0x55;	
    while (((PLLSTAT & (1 << 24)) == 0));	// Wait until the PLL is usable
    
    CCLKCFG = (Fcco/Fcclk - 1);				// set the CCLKCFG
 	PLLCON = 3;								// connect the PLL 
    PLLFEED = 0xAA;
    PLLFEED = 0x55;							
	while (((PLLSTAT & (3 << 25))!= (3 << 25)));	// Wait until the PLL is connected and locked
}		
/*********************************************************************************************************
** 函数名称 :IRQ_EINT0()
** 函数功能 :外部中断服务程序。
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************
*/
void __irq IRQ_EINT0 (void)
{
	EXTINT = (1<<0);	//清中断标志“”请在此句设置断点
	PLLinit();			//重新初始化PLL及时钟
    VICVectAddr = 0;
}
			
/*******************************************************************************************
** 函数名称 :main
** 函数功能 :演示外部中断唤醒掉电的CPU
** 入口参数 :无。
** 出口参数 :无
** 注意事项 :
*******************************************************************************************/
int main (void)
{
	PINSEL4 = 0x00100000;						// P2.10连接EINT0
	EXTMODE = 0x01;
	EXTPOLAR = 0x00;							//下降沿触发		
	EXTINT = (1<<0);
	
	INTWAKE       = 1<<0;						// 外部中断0可唤醒芯片
	
	IRQEnable();								// IRQ中断使能								
						
	/* 设置定时器0中断IRQ */
	VICIntSelect = 0x00;						// 所有中断通道设置为IRQ中断		
	VICVectPri14 = 00;							// 设置外部中断0中断最高优先级	
	VICVectAddr14 = (uint32)IRQ_EINT0;			// 设置中断服务程序地址	
	
	VICIntEnable = 1 << 14;						// 使能外部中断0中断	
	
	while (1)
	{
		PCONP = 0x00;							// 关闭定时器、RTC、UART等功能部件
		PCON  = 0x02;							// 系统进入掉电模式
	}								
	return (0); 
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -