AnsweredAssumed Answered

How to Switch the STM8L152 the sys clock source for HSI to LSI

Question asked by hu.bei on Feb 12, 2011
Latest reply on Apr 6, 2011 by Phil
I can change the sys clock source from  HSI to LSI success in the debug mode with ST_LINK in  the   IDE   Iar for stm8.
But  it can't success  when abort the  debug mode.  i need a help,someone can  help me.
This is my code:

                CLK_CKDIVR_CKM = 0;                 //系统时钟源不分频
                CLK_ICKCR_LSION = 1;                //启动LSI
                while(CLK_ICKCR_LSIRDY);            //等待LSI稳定
                CLK_SWCR_SWEN = 1;                  //允许时钟切换
                CLK_SWR = 0x02;                     //切换LSI为时钟源           
                while(CLK_SCSR != 0x02);            //等待LSI切换为系统时钟源
//                CLK_SWCR_SWEN = 0;                  //关闭时钟切换
//                CLK_ICKCR_HSION = 0;                //关闭HSI时钟

Outcomes