cancel
Showing results for 
Search instead for 
Did you mean: 

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

honami520
Associate
Posted on February 12, 2011 at 04:39

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??

#lsi-stm8l
1 REPLY 1
vincent.philippe
Associate II
Posted on April 06, 2011 at 11:26

Hi,

In fact, for switch clock source HSI --> LSI, I suggest to you to use driver commands something like that:

CLK_LSICmd(ENABLE);

CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);

CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);

CLK_SYSCLKSourceSwitchCmd(ENABLE);

while (((CLK->SWCR)& 0x01)==0x01);

I try it I don't see any problem in LSI when I abort the debug mode.

Best regards

Philippe