☆ 华大HC32F003☆ ---WDT例程分享(不断更新中......)

                              样例使用说明

☆适用领域:小家电,充电器,重合闸,遥控器,电子烟,燃气报警器,数显表,温控器,记录仪等行业。☆ 本文旨在抛砖引玉,其余具体使用欢迎加Q:3254478211或加群164973950相互交流、学习。

☆ 华大MCU单片机资料分享连接
HC32F003 HC32F005 HC32L110 HC32L136 HC32F030 HC32M140 HC32F146 HC32L150 HC32L156

作者:虹芯侠客1
来源:CSDN
原文:https://blog.csdn.net/jetson024/article/details/84619088
版权声明:本文为博主原创文章,转载请附上博文链接!

/****************************************************************************/
/
\file main.c
**
** A detailed description is available at
** @link Sample Group Some description @endlink
**
** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module.
**
******************************************************************************/

/******************************************************************************

  • Include files
    ******************************************************************************/

#include “wdt.h”
#include “lpm.h”
#include “gpio.h”

/******************************************************************************

  • Local pre-processor symbols/macros (’#define’)
    ******************************************************************************/

/******************************************************************************

  • Global variable definitions (declared in header file with ‘extern’)
    ******************************************************************************/

/******************************************************************************

  • Local type definitions (‘typedef’)
    ******************************************************************************/

/******************************************************************************

  • Local function prototypes (‘static’)
    ******************************************************************************/

/******************************************************************************

  • Local variable definitions (‘static’) *
    ******************************************************************************/

/******************************************************************************

  • Local pre-processor symbols/macros (’#define’)
    ******************************************************************************/
    #define T1_PORT (0)
    #define T1_PIN (3)

/*****************************************************************************

  • Function implementation - global (‘extern’) and local (‘static’)
    ****************************************************************************/
    /

** \brief Main function of project
**
** \return uint32_t return value, if needed
**
** This sample
**
******************************************************************************/
uint8_t u32CountWdt;
uint8_t Data=0xff;
uint8_t cnt=0;

static void WdtCallback(void)
{
// comment following to demonstrate the hardware watchdog reset
Data = ~Data;
Gpio_SetIO(T1_PORT,T1_PIN,Data);
u32CountWdt++;
}
int32_t main(void)
{
stc_wdt_config_t stcWdt_Config;
stc_lpm_config_t stcLpmCfg;

DDL_ZERO_STRUCT(stcWdt_Config);
DDL_ZERO_STRUCT(stcLpmCfg);

stcLpmCfg.enSLEEPDEEP = SlpDpDisable;//SlpDpEnable;
stcLpmCfg.enSLEEPONEXIT = SlpExtEnable;

Gpio_InitIO(T1_PORT,T1_PIN,GpioDirOut);
Gpio_SetIO(T1_PORT,T1_PIN,0);
Gpio_InitIO(3,3,GpioDirIn);

stcWdt_Config.u8LoadValue = 0x0b;//3.2s
stcWdt_Config.enResetEnable = WINT_EN;//WRESET_EN;
stcWdt_Config.pfnWdtIrqCb = WdtCallback;

Clk_SetPeripheralGate(ClkPeripheralWdt,TRUE);//
Wdt_Init(&stcWdt_Config);

Wdt_Start();
Gpio_SetIO(T1_PORT,T1_PIN,1);

#if 0
while(1 == Gpio_GetIO(3,3));//注意:此处如果用户测试深度休眠模式,此处不能屏蔽
Lpm_Config(&stcLpmCfg);
Lpm_GotoLpmMode();
#endif
while (1)
{
//cnt = Wdt_ReadWdtValue();
//Wdt_Feed();//测试喂狗功能时,放开屏蔽

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值