完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
如果想使用看门狗作为一个定时器,而不让看门狗定时器复位咋办
/*---------------------------------------------------------------------------------------------------------*/ /* */ /* Copyright(c) 2016 Nuvoton Technology Corp. All rights reserved. */ /* */ /*---------------------------------------------------------------------------------------------------------*/ //*********************************************************************************************************** // Nuvoton Technoledge Corp. // Website: http://www.nuvoton.com // E-Mail : MicroC-8bit@nuvoton.com // Date : Apr/21/2016 //*********************************************************************************************************** //*********************************************************************************************************** // File Function: N76E003 Watch Dog reste functiondemo code //*********************************************************************************************************** #include "N76E003.h" #include "Common.h" #include "Delay.h" #include "SFR_Macro.h" #include "Function_define.h" #define CFG_READ 0xC0 #define CFG_ERASE 0xE2 #define CFG_BYTE_PROGRAM 0xE1 /*********************************************************************** WDT CONFIG enable warning : this macro is only when ICP not enable CONFIG WDT function copy this marco code to you code to enable WDT reset. ************************************************************************/ void Enable_WDT_Reset_Config(void) { set_IAPEN; IAPAL = 0x04; IAPAH = 0x00; IAPFD = 0x0F; IAPCN = CFG_BYTE_PROGRAM; set_CFUEN; set_IAPGO; //trigger IAP while((CHPCON&SET_BIT6)==SET_BIT6); //check IAPFF (CHPCON.6) clr_CFUEN; clr_IAPEN; } /*********************************************************************** WDT CONFIG disable warning : this macro is for CONFIG already enable WDT Reset to disable. Since erase CONFIG is full page step 1. storage CONFIG value in RAM step 2. modify RAM CONFIG4 WDT value to disable step 3. erase CONFIG page step 4. re writer CONFIG. ************************************************************************/ void Disable_WDT_Reset_Config(void) { UINT8 cf0,cf1,cf2,cf3,cf4; set_IAPEN; IAPAL = 0x00; IAPAH = 0x00; IAPCN = CFG_READ; set_IAPGO; //Storage CONFIG0 data cf0 = IAPFD; IAPAL = 0x01; set_IAPGO; //Storage CONFIG1 data cf1 = IAPFD; IAPAL = 0x02; set_IAPGO; //Storage CONFIG2 data cf2 = IAPFD; IAPAL = 0x03; set_IAPGO; //Storage CONFIG3 data cf3 = IAPFD; IAPAL = 0x04; set_IAPGO; //Storage CONFIG4 data cf4 = IAPFD; cf4 |= 0xF0; //Moidfy Storage CONFIG4 data disable WDT reset set_CFUEN; IAPCN = CFG_ERASE; //Erase CONFIG all IAPAH = 0x00; IAPAL = 0x00; IAPFD = 0xFF; set_IAPGO; IAPCN = CFG_BYTE_PROGRAM; //Write CONFIG IAPFD = cf0; set_IAPGO; IAPAL = 0x01; IAPFD = cf1; set_IAPGO; IAPAL = 0x02; IAPFD = cf2; set_IAPGO; IAPAL = 0x03; IAPFD = cf3; set_IAPGO; IAPAL = 0x04; IAPFD = cf4; set_IAPGO; clr_CFUEN; clr_IAPEN; } /************************************************************************************************************ * Main function ************************************************************************************************************/ void main (void) { Set_All_GPIO_Quasi_Mode; clr_GPIO1; Timer0_Delay1ms(50); //toggle I/O to show MCU Reset set_GPIO1; Timer0_Delay1ms(50); clr_GPIO1; Timer0_Delay1ms(50); set_GPIO1; Timer0_Delay1ms(50); //---------------------------------------------------------------------------------------------- // WDT Init !!! ENABLE CONFIG WDT FIRST !!! // Warning: // Always check CONFIG WDT enable first, CONFIG not enable, SFR can't enable WDT reset // Please call Enable_WDT_Reset_Config() function to enable CONFIG WDT reset //---------------------------------------------------------------------------------------------- // Enable_WDT_Reset_Config(); //Software enable WDT reset CONFIG setting TA=0xAA;TA=0x55;WDCON|=0x07; //Setting WDT prescale set_WDCLR; //Clear WDT timer while((WDCON|~SET_BIT6)==0xFF); //confirm WDT clear is ok before into power down mode // EA = 1; set_WDTR; //WDT run Disable_WDT_Reset_Config(); //Software disable WDT reset CONFIG setting while (1) { clr_GPIO1; Timer0_Delay1ms(100); set_GPIO1; Timer0_Delay1ms(100); clr_GPIO1; Timer0_Delay1ms(100); set_GPIO1; Timer0_Delay1ms(100); clr_GPIO1; set_PD; } } |
|
相关推荐
1个回答
|
|
如果想使用看门狗作为一个定时器,而不让看门狗定时器复位,需要在程序中定期喂狗(向看门狗发送喂狗信号),这样看门狗就不会进行复位操作。具体实现方法可以参考所使用的硬件平台的手册或者资料。
|
|
|
|
只有小组成员才能发言,加入小组>>
3280 浏览 9 评论
2958 浏览 16 评论
3460 浏览 1 评论
9004 浏览 16 评论
4052 浏览 18 评论
1115浏览 3评论
573浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
571浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2303浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1860浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 16:10 , Processed in 1.459954 second(s), Total 82, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号