obsidian-notes/MCU/WCH-南京沁恒/CH57x.md
murmur 5a8d7e0b03 Matebook更新了1个文件
Affected files:
MCU/WCH-南京沁恒/CH57x.md
2024-04-23 22:04:32 +08:00

61 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
created: 2024-04-23
tags:
- "#RISC_V"
- "#低功耗"
- "#CH57X"
- 代码块
- mcu
---
# 低功耗
使用官方例子最低功耗仍有约2mA经察默认GPIO的配置由`GPIO_ModeIN_PU`改为`GPIO_ModeIN_PD`能显著降低功耗可低至约35uA代码如下
```c hl:26-27
/*********************************************************************
* @fn DebugInit
*
* @brief 调试初始化
*
* @return none
*/
void DebugInit(void)
{
GPIOA_SetBits(GPIO_Pin_9);
GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA);
UART1_DefInit();
}
/*********************************************************************
* @fn main
*
* @brief 主函数
*
* @return none
*/
int main()
{
SetSysClock(CLK_SOURCE_PLL_60MHz);
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PU);
/* 配置串口调试 */
DebugInit();
PRINT("Start @ChipID=%02x\n", R8_CHIP_ID);
DelayMs(200);
PRINT("sleep mode sleep \n");
DelayMs(2);
LowPower_Sleep(RB_PWR_RAM16K | RB_PWR_RAM2K); //只保留14+2K SRAM 供电
HSECFG_Current(HSE_RCur_100); // 降为额定电流(低功耗函数中提升了HSE偏置电流)
DelayMs(5);
PRINT("wake.. \n");
DelayMs(500);
while(1);
}
```
参考的一些例子:
[基于CH573的BLE温湿度传感器](https://yuanze.wang/posts/ch573-temp-humid-beacon/),源码可编译
[CH571F无线温湿度计](https://oshwhub.com/thelight/ch571f-wu-xian-wen-shi-du-ji),源码不能正常编译