📄 main.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"
#include "watchdog.h"
#define INT_WDT 0 //看门狗中断号
#define BEEP 1<<7 //P0.7 控制蜂鸣器
#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)
{
}
/*********************************************************************************************************
** 函数名称: WDT_ISR()
** 函数功能: 看门狗中断服务函数。
** 入口参数: 无
** 出口参数: 无
********************************************************************************************************/
void WDT_ISR(void)
{
uint32 i;
//蜂鸣器鸣叫
IO0CLR = BEEP;
for(i = 0; i < 0x7fffff; i++);
IO0SET = BEEP;
WDMOD = 0; //清零看门狗超时标志
VICIntEnClr = 1<<INT_WDT; //看门狗溢出中断只能通过禁止VIC的方式返回
VICVectAddr = 0x00; //通知VIC中断结束
}
/*********************************************************************************************************
** 函数名称: Main()
** 函数功能: 错误喂狗产生WDT中断演示。
********************************************************************************************************/
void Main(void)
{
uint32 i;
TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA); // don't delete
while((PLLSTAT & (1 << 10)) == 0); // can delete
PINSEL1 = 0x00000000;
IO0DIR = BEEP;
IO0SET = BEEP;
WatchDogInit(60000,0); //初始化看门狗,定时时间:tpclk×4×60000,禁止复位功能
SetISR(INT_WDT, 0,(unsigned int)WDT_ISR); //设置看门狗中断服务函数
IRQEnable(); //打开中断
for(i = 0; i < 0x3fff; i++);
WDFEED = 0xAA;
WDFEED = 0x54; //错误的喂狗序列,将导致看门狗中断
while(1);
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -