📄 main.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: 李仲生
** Created date: 2007-03-14
** Version: 1.0
** Descriptions: PLL中断示例程序
**
**------------------------------------------------------------------------------------------------------
** Modified by: Liuyanlong
** Modified date: 2007-08-17
** Version:
** Descriptions: 对代码风格和注释进行校对、修改
**
** Rechecked by : Litiantian
********************************************************************************************************/
#include "config.h"
/*********************************************************************************************************
** 函数名称 :IRQ_PLL
** 函数功能 :PLL中断服务程序
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************/
void __irq IRQ_PLL(void)
{
PLLCON = 3; // 连接PLL
PLLFEED = 0xAA;
PLLFEED = 0x55;
while (((PLLSTAT & (3 << 25)) != (3 << 25))); // 等待PLL连接并锁定
VICIntEnClr = 1 << 12; // 禁止PLL中断
VICVectAddr = 0x00; // 通知VIC中断处理结束
}
/*********************************************************************************************************
** 函数名称 :main
** 函数功能 :演示PLL中断
** 注意事项 :在程序运行前需要在PLL中断服务程序内设置一断点。然后在全速运行
**********************************************************************************************************/
int main(void)
{
/* 先断开PLL */
if (PLLSTAT & (1 << 25)) // 如果PLL连接
{
PLLCON = 0x01;
PLLFEED = 0xAA; // 断开PLL
PLLFEED = 0x55;
PLLCON = 0x00;
PLLFEED = 0xAA;
PLLFEED = 0x55;
}
else
{
if (PLLSTAT & (1 << 24)) // 如果PLL使能 // 如果PLL已被使能,则先禁止PLL
{
PLLCON = 0x00;
PLLFEED = 0xAA;
PLLFEED = 0x55;
}
}
IRQEnable(); // IRQ中断使能
/* 设置PLL中断为IRQ */
VICIntSelect = 0x00; // 所有中断通道设置为IRQ中断
VICVectPri12 = 0; // 设置PLL中断最高优先级
VICVectAddr12 = (uint32)IRQ_PLL; // 设置中断服务程序地址
CLKSRCSEL = 0x01; // 选择OSC作为PLL 时钟源
PLLCON = 1; // 使能但不连接PLL
PLLCFG = (((PLL_NValue - 1) << 16) | (PLL_MValue - 1));// 设置PLLCFG
PLLFEED = 0xAA;
PLLFEED = 0x55;
VICIntEnable = (1 << 12); // 使能PLL中断
while (1);
return (0);
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -