bc... [盗版]

wdg.c ( File view )

  • By Karma_w 2015-06-09
  • View(s):16
  • Download(s):1
  • Point(s): 1
			#include "wdg.h"
#include "led.h"
//////////////////////////////////////////////////////////////////////////////////	 
//本程序只供学习使用,未经作者许可,不得用于其它任何用途
//Mini STM32开发板
//看门狗 驱动代码		   
//正点原子@ALIENTEK
//技术论坛:www.openedv.com
//修改日期:2010/12/02
//版本:V1.0
//版权所有,盗版必究。
//Copyright(C) 正点原子 2009-2019
//All rights reserved
////////////////////////////////////////////////////////////////////////////////// 	  
 		   

//初始化独立看门狗
//prer:分频数:0~7(只有低3位有效!)
//分频因子=4*2^prer.但最大值只能是256!
//rlr:重装载寄存器值:低11位有效.
//时间计算(大概):Tout=((4*2^prer)*rlr)/40 (ms).
void IWDG_Init(u8 prer,u16 rlr) 
{

	IWDG->KR=0X5555;//使能对IWDG->PR和IWDG->RLR的写		 										  
  	IWDG->PR=prer;  //设置分频系数   
  	IWDG->RLR=rlr;  //从加载寄存器 IWDG->RLR  
	IWDG->KR=0XAAAA;//reload											   
  	IWDG->KR=0XCCCC;//使能看门狗	

}
//喂独立看门狗
void IWDG_Feed(void)
{

	IWDG->KR=0XAAAA;//reload											   

}

//保存WWDG计数器的设置值,默认为最大.
u8 WWDG_CNT=0x7f;
//初始化窗口看门狗
//tr   :T[6:0],用于存储计数器的值
//wr   :W[6:0],用于存储窗口值
//fprer:窗口看门狗的实际设置
//低2位有效.Fwwdg=PCLK1/4096/2^fprer.
void WWDG_Init(u8 tr,u8 wr,u8 fprer)
{
							  
	RCC->APB1ENR|=1<<11;	//使能wwdg时钟
	WWDG_CNT=tr&WWDG_CNT;   //初始化WWDG_CNT.									   
	WWDG->CFR|=fprer<<7;    //PCLK1/4096再除2^fprer
	WWDG->CFR|=1<<9;        //使能提前唤醒中断
	WWDG->CFR&=0XFF80;     
	WWDG->CFR|=wr;		    //设定窗口值     
	WWDG->CR|=WWDG_CNT|(1<<7); //开启看门狗,设置7位计数器   							   
	MY_NVIC_Init(2,3,WWDG_IRQChannel,2);//抢占2,子优先级3,组2	   

}
//重设置WWDG计数器的值
void WWDG_Set_Counter(u8 cnt)
{

	WWDG->CR|=(cnt&0x7F);//重设置7位计数器

}
//窗口看门狗中断服务程序
void WWDG_IRQHandler(void)
{
				    	
	u8 wr,tr;  
 	wr=WWDG->CFR&0X7F;
	tr=WWDG->CR&0X7F;
	if(tr<wr)WWDG_Set_Counter(WWDG_CNT);//只有当计数器的值,小于窗口寄存器的值才能写CR!!	  			    
	WWDG->SR=0X00;//清除提前唤醒中断标志位
	LED1=!LED1;

}



















			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.97 kB
01.97 kB
01.97 kB
adc.c2.48 kB2015-06-03 11:04
adc.h693.00 B2011-01-12 21:19
01.97 kB
dma.c1.31 kB2010-06-07 16:30
dma.h378.00 B2010-06-07 16:30
01.97 kB
exti.c1.71 kB2011-01-12 20:50
exti.h628.00 B2011-01-12 20:51
01.97 kB
key.c1.73 kB2013-04-03 14:18
key.h839.00 B2011-01-12 20:46
01.97 kB
FONT.H15.78 kB2010-06-21 11:18
ILI93xx.c38.75 kB2012-10-25 23:18
LCD.h8.94 kB2012-10-25 22:28
01.97 kB
led.c910.00 B2013-04-03 14:18
led.h288.00 B2010-05-27 17:30
01.97 kB
FONT.H15.78 kB2010-03-19 17:16
oled.c6.70 kB2011-01-12 21:02
oled.h1.59 kB2011-01-12 21:02
01.97 kB
rtc.c7.75 kB2011-01-12 22:04
rtc.h1.35 kB2011-01-12 21:15
01.97 kB
timer.c2.10 kB2015-06-03 11:38
timer.h724.00 B2011-01-12 20:59
01.97 kB
wdg.c2.04 kB2011-01-12 20:56
wdg.h756.00 B2011-01-12 20:56
01.97 kB
wkup.c1.85 kB2011-01-12 21:18
wkup.h728.00 B2011-01-12 21:18
keilkilll.bat399.00 B2011-04-23 10:24
README.TXT377.00 B2012-07-19 22:20
01.97 kB
01.97 kB
delay.c2.02 kB2013-04-03 12:14
delay.h905.00 B2013-04-03 12:14
01.97 kB
cortexm3_macro.h2.17 kB2009-05-07 14:42
stm32f10x_conf.h6.05 kB2009-05-07 14:42
stm32f10x_it.h4.42 kB2012-12-18 12:35
stm32f10x_map.h27.63 kB2009-05-07 14:42
stm32f10x_nvic.h18.75 kB2009-05-07 14:42
stm32f10x_type.h3.31 kB2009-05-07 14:42
sys.c6.69 kB2013-04-03 12:13
sys.h3.78 kB2013-04-03 12:13
01.97 kB
usart.c3.35 kB2015-06-03 11:28
usart.h1,010.00 B2015-06-03 10:57
01.97 kB
adc.crf34.24 kB2015-06-03 11:04
adc.d298.00 B2015-06-03 11:04
adc.o39.02 kB2015-06-03 11:04
delay.crf31.84 kB2015-06-03 10:54
delay.d286.00 B2015-06-03 10:54
delay.o37.45 kB2015-06-03 10:54
ili93xx.crf80.82 kB2015-06-03 10:57
ili93xx.d592.00 B2015-06-03 10:57
ili93xx.o79.87 kB2015-06-03 10:57
JLinkLog.txt59.16 kB2015-06-03 11:43
JLinkSettings.ini578.00 B2013-04-03 14:19
key.crf34.17 kB2015-06-03 10:54
key.d332.00 B2015-06-03 10:54
key.o40.01 kB2015-06-03 10:54
led.crf33.41 kB2015-06-03 10:54
led.d298.00 B2015-06-03 10:54
led.o38.35 kB2015-06-03 10:54
modbus.c5.44 kB2015-06-03 11:38
modbus.crf40.08 kB2015-06-03 11:38
modbus.d478.00 B2015-06-03 11:38
modbus.h404.00 B2015-06-03 10:54
modbus.o47.92 kB2015-06-03 11:38
rtc.crf41.95 kB2015-06-03 10:57
rtc.d434.00 B2015-06-03 10:57
rtc.o48.63 kB2015-06-03 10:57
STM32F10x.d28.00 B2015-06-03 10:54
STM32F10x.lst34.54 kB2015-06-03 10:54
stm32f10x.o5.58 kB2015-06-03 10:54
STM32F10x.s11.04 kB2009-12-22 19:16
sys.crf35.34 kB2015-06-03 10:54
sys.d264.00 B2015-06-03 10:54
sys.o42.51 kB2015-06-03 10:54
TEST.axf37.47 kB2015-06-03 11:43
TEST.build_log.htm1.36 kB2015-06-03 11:44
test.c601.00 B2015-06-03 11:41
test.crf51.11 kB2015-06-03 11:41
test.d792.00 B2015-06-03 11:41
TEST.hex13.17 kB2015-06-03 11:43
TEST.htm43.73 kB2015-06-03 11:43
TEST.lnp339.00 B2015-06-03 11:43
TEST.map64.78 kB2015-06-03 11:43
test.o54.43 kB2015-06-03 11:41
TEST.Opt2.03 kB2013-04-03 14:21
TEST.plg249.00 B2014-03-16 19:17
TEST.sct479.00 B2014-02-21 11:13
TEST.tra1.38 kB2014-02-21 11:13
TEST.Uv23.21 kB2013-04-03 14:21
TEST.uvgui.Administrator69.44 kB2013-04-03 14:20
TEST.uvgui.wjc72.16 kB2015-06-03 11:44
TEST.uvgui.WuJiChao67.42 kB2014-03-16 19:17
TEST.uvgui_wjc.bak72.08 kB2015-06-03 11:42
TEST.uvgui_WuJiChao.bak67.35 kB2014-02-21 11:21
TEST.uvopt10.12 kB2015-06-03 11:44
TEST.uvproj16.86 kB2015-06-03 11:42
TEST_Target8.60 kB2015-06-03 11:43
TEST_uvopt.bak10.12 kB2015-06-03 11:42
TEST_uvproj.bak17.39 kB2015-06-02 14:35
timer.crf38.84 kB2015-06-03 11:38
timer.d462.00 B2015-06-03 11:38
timer.o43.37 kB2015-06-03 11:38
usart.crf38.59 kB2015-06-03 11:28
usart.d388.00 B2015-06-03 11:28
usart.o43.36 kB2015-06-03 11:28
wdg.crf34.45 kB2015-06-03 10:54
wdg.d330.00 B2015-06-03 10:54
wdg.o41.05 kB2015-06-03 10:54
wkup.crf34.14 kB2015-06-03 10:54
wkup.d378.00 B2015-06-03 10:54
wkup.o41.15 kB2015-06-03 10:54
...

wdg.c (571.52 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D