[综合信息]

华大HC32F003 ---WDT例程分享(转)

[复制链接]
1269|3
手机看帖
扫描二维码
随时随地手机跟帖
drer|  楼主 | 2019-6-19 11:04 | 显示全部楼层 |阅读模式
/****************************************************************************/
/ \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
**
******************************************************************************/


使用特权

评论回复
drer|  楼主 | 2019-6-19 11:04 | 显示全部楼层
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++;
}


使用特权

评论回复
drer|  楼主 | 2019-6-19 11:06 | 显示全部楼层
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();//测试喂狗功能时,放开屏蔽
}
}

使用特权

评论回复
kaffebean2020| | 2020-5-1 15:06 | 显示全部楼层
您好,我测试深度睡眠的时候把while(1 == Gpio_GetIO(3,3));屏蔽了,现在不能烧录程序了,是什么原因呢?怎么解决?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

60

主题

3309

帖子

4

粉丝