博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2018.1.3 Set STM8L052C6T6 to Ultra Low Power.
阅读量:5889 次
发布时间:2019-06-19

本文共 3112 字,大约阅读时间需要 10 分钟。

I would like to set STM8L052C6T6 to Ultra Low Power. I tried different setting on I/O and refer to the discovery broad example, I still struggle on this issue, I am worried hand-solder to damage STM8L052C6T6 chip, Here is my code, all I/O is open!

 

TEST 1: Init all the I/O to GPIO_Mode_Out_PP_Low_Slow, then Set all I/O to GPIO_SetBits, the current is 95.3uA.

 

void main(void)

{

      CLK_DeInit();    

 

  GPIO_DeInit(GPIOA);

  GPIO_DeInit(GPIOB);

      GPIO_DeInit(GPIOC);

  GPIO_DeInit(GPIOD);

      GPIO_DeInit(GPIOE);

      GPIO_DeInit(GPIOF);

/* Port A in output push-pull 0 */

  GPIO_Init(GPIOA, GPIO_Pin_All ,GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOE, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOF, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

     

  GPIO_SetBits(GPIOA,GPIO_Pin_All);

      GPIO_SetBits(GPIOB,GPIO_Pin_All);

      GPIO_SetBits(GPIOC,GPIO_Pin_All);

      GPIO_SetBits(GPIOD,GPIO_Pin_All);

      GPIO_SetBits(GPIOE,GPIO_Pin_All);

      GPIO_SetBits(GPIOF,GPIO_Pin_All);

     

  disableInterrupts();       

     

      while(1){

            nop();

            nop();

            nop();           

            halt();          

            nop();

            nop();

            nop();           

      }

}

 

TEST 2: Init all the I/O to GPIO_Mode_Out_PP_Low_Slow, then Set all I/O to GPIO_SetBits, the current is 12.44mA.

void main(void)

{

      CLK_DeInit();    

  GPIO_DeInit(GPIOA);

  GPIO_DeInit(GPIOB);

      GPIO_DeInit(GPIOC);

  GPIO_DeInit(GPIOD);

      GPIO_DeInit(GPIOE);

      GPIO_DeInit(GPIOF);

/* Port A in output push-pull 0 */

  GPIO_Init(GPIOA, GPIO_Pin_All ,GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOE, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

      GPIO_Init(GPIOF, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);

  GPIO_ResetBits(GPIOA,GPIO_Pin_All);

      GPIO_ResetBits(GPIOB,GPIO_Pin_All);

      GPIO_ResetBits(GPIOC,GPIO_Pin_All);

      GPIO_ResetBits(GPIOD,GPIO_Pin_All);

      GPIO_ResetBits(GPIOE,GPIO_Pin_All);

      GPIO_ResetBits(GPIOF,GPIO_Pin_All);

  disableInterrupts();       

      while(1){

            nop();

            nop();

            nop();           

            halt();          

            nop();

            nop();

            nop();           

      }

}

 

Answer:

Dose  pcb have no peripheral circuit?

Please try to set the IO PORT to GPIO_Mode_In_PU_No_IT.

 

Last problem(Ultra Low Power) is fixed, I got another problem about the LSE(Low Speed external) clock not correct.

CLK_LSEConfig(CLK_LSE_ON);

RTC_Config();

RTC_SetWakeUpCounter(1024/8-1);     //16Hz

RTC_WakeUpCmd(ENABLE);

I setup by above code and measure toggle I/O in the 16Hz interrupt, but I got 17.86Hz, I also try this in the discovery board, then measure the frequency is 20Hz. How can I know the reason?

When RTC wake up from halt() mode, you need disable the RTC wake up and enable RTC wake up before entering the halt() mode.

Please also try  adding the following two functions before entering the halt() mode.

PWR_FastWakeUpCmd(ENABLE);

PWR_UltraLowPowerCmd(ENABLE);

 

All of the above operations are due to the application code that takes up the runtime of the RTC. And ensure the RTC clock source is LSE.

转载于:https://www.cnblogs.com/huangbaobaoi/p/8194406.html

你可能感兴趣的文章
影响企业信息化成败的几点因素
查看>>
SCCM 2016 配置管理系列(Part8)
查看>>
struts中的xwork源码下载地址
查看>>
ABP理论学习之仓储
查看>>
我的友情链接
查看>>
CentOS图形界面和命令行切换
查看>>
HTML5通信机制与html5地理信息定位(gps)
查看>>
加快ALTER TABLE 操作速度
查看>>
PHP 程序员的技术成长规划
查看>>
python基础教程_学习笔记19:标准库:一些最爱——集合、堆和双端队列
查看>>
js replace,正则截取字符串内容
查看>>
作业2
查看>>
nginx的信号量
查看>>
云im php,网易云IM
查看>>
DEFERRED_SEGMENT_CREATION
查看>>
Ada boost学习
查看>>
开源 java CMS - FreeCMS2.3字典管理
查看>>
block,inline和inline-block概念和区别
查看>>
移动端常见随屏幕滑动顶部固定导航栏背景色透明度变化简单jquery特效
查看>>
javascript继承方式详解
查看>>