本帖最后由 shibing2005 于 2019-12-31 14:01 编辑
公司最近在试用国产芯片华大的HC32L1330J8TA的,写了一些程序功能都没有问题就是深度睡眠模式下始终电流太大。希望大家给帮忙分析下问题出在哪里?
//*****************************************************************************
int32_t main(void)
{
App_ClkInit();
App_LedInit(); //< LED端口初始化
R_LED_L;
delay1ms(1000);
delay1ms(1000);
delay1ms(1000);
delay1ms(1000);
R_LED_H;
delay1ms(500);
_LowPowerModeGpioSet();
Lpm_GotoSleep(TRUE);//进入深度睡眠模式 FALSE:唤醒后不再自动进入休眠
while(1)
{
}
}
//时钟初始化配置
void App_ClkInit(void)
{
stc_sysctrl_clk_cfg_t stcCfg;
Sysctrl_SetRCHTrim(SysctrlRchFreq4MHz);
stcCfg.enClkSrc = SysctrlClkRCH;
stcCfg.enHClkDiv = SysctrlHclkDiv1;
stcCfg.enPClkDiv = SysctrlPclkDiv1;
Sysctrl_ClkInit(&stcCfg);
Sysctrl_ClkSourceEnable(SysctrlClkXTL, TRUE);
}
void App_LedInit(void)
{
stc_gpio_cfg_t stcGpioCfg;
Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
stcGpioCfg.enDir = GpioDirOut;
stcGpioCfg.enPu = GpioPuDisable;
stcGpioCfg.enPd = GpioPdEnable;
Gpio_ClrIO(R_LED_PORT, R_LED_PIN);
Gpio_Init(R_LED_PORT, R_LED_PIN, &stcGpioCfg);
}
static void App_LowPowerModeGpioSet(void)
{
///< 打开GPIO外设时钟门控
Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
//swd as gpio
Sysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE);
///< 配置为数字端口
M0P_GPIO->PAADS = 0;
M0P_GPIO->PBADS = 0;
M0P_GPIO->PCADS = 0;
M0P_GPIO->PDADS = 0;
///< 配置为端口输入(除LED端口外)
M0P_GPIO->PADIR = 0XFFFF;
M0P_GPIO->PBDIR = 0XFFFF;
M0P_GPIO->PCDIR = 0XDFFF;
M0P_GPIO->PDDIR = 0XFFFF;
///< 输入下拉
M0P_GPIO->PAPD = 0xFFFF;
M0P_GPIO->PBPD = 0xFFFF;
M0P_GPIO->PCPD = 0xFFFF;
M0P_GPIO->PDPD = 0xFFFF;
}
//*****************************************************************************
|