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

📄 main.c

📁 arm7 lpc2103 的keil 程序开发包 非常有参考价值
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                 http://www.zyinside.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:           main.c
** Last modified Date:  2006-02-22
** Last Version:        1.0
** 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
**------------------------------------------------------------------------------------------------------
** Modified by: 
** Modified date:
** Version: 
** Descriptions: 
**
********************************************************************************************************/

#define IN_MAIN
#include "config.h"

 #define BEEP     1 << 7                        //P0.7控制蜂鸣器
 
 #define PLL_INT   12			                //PLL中断号
												  
#pragma import(__use_no_semihosting_swi)        //don't delete this line
/*********************************************************************************************************
** Function name:			IRQ_Exception
**
** Descriptions:			interrupt exceptional handler , change it as needed
**                          don't delete this function 
** input parameters:		None
** Returned value:			None
**         
**
** Created by:				Chenmingji
** Created Date:			2006/02/22
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
 void  IRQ_Exception(void)
{
}


/*********************************************************************************************************
** 函数名称:  DelayNS(uint32 dly)
**
** 功能描述:  延时函数
**
** 输入参数:  dly     延时值
** 输出参数:  无
** 返回值:   无       
********************************************************************************************************/
void DelayNS(uint32 dly)
{
    uint32 i;
    for(; dly > 0; dly--)
        for(i = 0; i < 5000; i++);
}



/*********************************************************************************************************
** 函数名称:  PLL_ISR(void)
**
** 功能描述:  PLL中断服务函数,
**
** 输入参数:  无
** 输出参数:  无
** 返回值:   无       
********************************************************************************************************/
void PLL_ISR(void)
{    
    PLLCON = 3;                          //PLL使能和连接
    PLLFEED = 0xAA;						 //发送PLL馈送序列
    PLLFEED = 0x55;
    
    IO0CLR = BEEP;						 //BEEP发声
    DelayNS(400);
    IOSET = BEEP;						 //关闭BEEP
    
    VICIntEnClr = 1 << 12;				 //禁止PLL中断
    VICVectAddr = 0;    				 //向量中断处理结束
}


/*********************************************************************************************************
** Function name:           Main
**
** Descriptions:            更改PLL设置,等待PLL中断。
**
** input parameters:        None
** Returned value:          None
**         
**
** Created by:              Chenmingji
** Created Date:            2006/02/22
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Main(void)
{
    TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA);      // don't delete
    while((PLLSTAT & (1 << 10)) == 0);                      // can delete
    
    PINSEL0 = 0;						        //设置引脚连接GPIO
    									        
    IO0DIR = BEEP;						        //BEEP控制口输出方式   
    IO0SET = BEEP;                              //关闭BEEP
    									        
    PLLCON = 1;    						        //使能PLL
    PLLCFG = 0x25;                              //设置M=6, P=2
    
    
    PLLFEED = 0xAA;						        //发送PLL馈送序列
    PLLFEED = 0x55;
    
    SetISR(PLL_INT,0, (unsigned int)PLL_ISR);   //设置PLL中断
    IRQEnable();								//使能IRQ中断
        
    while(1);
}


/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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