2018.1.4 Set STM8L052C6T6 to Ult

作者: Berry521 | 来源:发表于2018-01-04 17:23 被阅读14次

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.

好文要顶 关注我 收藏该文  

相关文章

  • 2018.1.4 Set STM8L052C6T6 to Ult

    I would like to set STM8L052C6T6 to Ultra Low Power. I tr...

  • 让价值投资者更有价值 ULT走向价值之路

    ULT从诞生以来就注重价值流通。创立一周年时,ULT的持有者曾问起,ULT涨得这么猛,背后的逻辑是什么?答案很简单...

  • 三毛《送你一匹马》

    2018.1.4 于交医

  • 冬吟白雪诗

    于2018.1.4日中午拍摄

  • 项目经历叙述流程

    GATK软件pairhmm算法FPGA加速(altera arria 10芯片 xilinx Kintex ult...

  • 社交圈

    2018.1.4 圈子不同,不必强融。 离开了一个不同频的老朋友。 2018.1.4 最优博弈原则 我选择完全的信任你

  • 2018.1.4

    晚上,孩子给我当了回老师。“妈妈,你看看这个数轴上有多少数?”。“有20个数。”我故意说错。“妈妈,你得数...

  • 2018.1.4

    今天我看了一本书《你的灯亮着吗》(发现问题的真正所在),感觉特别有趣,但也被书里的内容绕得有点晕乎——问题是什么?...

  • 2018.1.4

    今天很有意思的一天。听肖宽元老师讲《易经》,易经风水如何旺运。 说真的,本人很好奇,很感兴趣。以前虽有听过但觉得神...

  • 2018.1.4

    2018年的第一场雪,从明天开始放假1.5-1.10小长假开始。可以美美的睡懒觉了。

网友评论

    本文标题:2018.1.4 Set STM8L052C6T6 to Ult

    本文链接:https://www.haomeiwen.com/subject/dnzrnxtx.html