STM8->RCC

Publisher:Dingsir1902Latest update time:2019-01-26 Source: eefocusKeywords:STM8  RCC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Try to wake up the halt() low power mode through the RTC interrupt. A low power clock source is needed as the RTC running clock. Select LSI's 16-division clock as the clock source:


void RCC_LSI(void)

{

    CLK_LSICmd (ENABLE);   

    CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);

    while(CLK_GetFlagStatus(CLK_FLAG_LSIRDY)==RESET);

    CLK_SYSCLKSourceSwitchCmd (ENABLE);

    if(CLK_GetSYSCLKSource()==CLK_SYSCLKSource_LSI)

     { 

             CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_16); 

     } 

}


RTC interrupt settings:


      RTC_DeInit();

      CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);   

      CLK_RTCClockConfig(CLK_RTCCLKSource_LSI, CLK_RTCCLKDiv_64); 

      RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16); 

      RTC_ITConfig(RTC_IT_WUT, ENABLE);

      RTC_SetWakeUpCounter(time);

      RTC_ClearITPendingBit(RTC_IT_WUT); 


        There is no direct enable here because during the debugging process, this part of the settings is under high-speed clock. If all of this part of the settings are placed after RCC_LSI(), it will get stuck, so only RTC_WakeUpCmd(ENABLE) is placed after the RCC_LSI() function.


      After the halt() or wfi() mode is awakened by the RTC interrupt, it switches back to the high-speed internal clock:


void RCC_HSI(void)

        CLK_HSICmd(ENABLE);

         CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);

        while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY)==RESET);

        CLK_SYSCLKSourceSwitchCmd (ENABLE);

        if(CLK_GetSYSCLKSource()==CLK_SYSCLKSource_HSI)

        {        

                CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1); 

        }

}     


When trying to switch directly from LSI to HSI and failing, an error occurs when STLINK connects to the MCU:


         Failed to get execution status: SWIM error [30004]: Comm timeout. Because it occurs during debugging, there is no sudden hardware abnormality. This connection error can only be attributed to the MCU system clock not working. In this case, it is because the clock does not transition normally. It occurs when switching the clock from LSI to HSI during debugging. According to some clues obtained on the Internet, it may be related to the -"|" or - of the register operation.


When developing with IAR for STM8, if the project is large and the structure is complex, or the file name is changed frequently, the software may crash:


Fatal Error[Pe1696]: cannot open source file "stm8l15x_pwr.h". Due to the crash of IAR software, the originally normal project reported many such errors. I had to add the reference folder again.



There is another type of error:


Fatal error: Unknown exception in driver (SD1) Session aborted!


       The answer that can be found on the Internet is that this is because IAR is not on the same system disk as Texas Instruments, but this is also sudden and should not be related to the problem of installation directory. After the project is completed, this problem strangely disappeared.

Keywords:STM8  RCC Reference address:STM8->RCC

Previous article:Problems with using printf to print floating point numbers in a single chip microcomputer
Next article:STM8->GPIO

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号