在线时间0 小时
UID80090
ST金币0
蝴蝶豆0
注册时间2007-7-30
新手上路
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-7-11 18:07:33
|
显示全部楼层
a0a.1 0b0c
回复:关于STM8L时钟切换问题
BYTE System_Clk_AutoSwitch(BYTE newsrc)
{
WORD timeout=0xffff;
//BYTE oldsrc = CLK_SCSR; //上一时钟源
CLK_SWCR_SWEN =0;
switch(newsrc)
{
case 1: CLK_ICKCR_HSION = 1;while (CLK_ICKCR_HSIRDY == 0);CLK_CKDIVR_CKM = 0;
CLK_SWCR_SWEN = 1;CLK_SWR = 0x01;while (CLK_SWCR_SWBSY & timeout);
CLK_SWCR_SWEN =0;break; //HSI
case 2: CLK_ICKCR_LSION = 1;while (CLK_ICKCR_LSIRDY == 0);CLK_CKDIVR_CKM = 0;
CLK_SWCR_SWEN = 1;CLK_SWR = 0x02;while (CLK_SWCR_SWBSY & timeout);
CLK_SWCR_SWEN =0;break; //LSI
case 3: CLK_ECKCR_HSEON = 1;while (CLK_ECKCR_HSERDY == 0);CLK_CKDIVR_CKM = 0;CLK_SWCR_SWEN =0;
CLK_SWCR_SWEN = 1;CLK_SWR = 0x04;while (CLK_SWCR_SWBSY & timeout);
CLK_SWCR_SWEN =0;break; //HSE
case 4: CLK_ECKCR_LSEON = 1;while (CLK_ECKCR_LSERDY == 0);CLK_CKDIVR_CKM = 0;
CLK_SWCR_SWEN = 1;CLK_SWR = 0x08;while (CLK_SWCR_SWBSY & timeout);
CLK_SWCR_SWEN =0;break; //LSE
default : break;
}
}
这是我的代码,请帮忙看看问题出在哪里。主程序第一条就是 BYTE System_Clk_AutoSwitch(LSE),就报以上错误。若执行BYTE System_Clk_AutoSwitch(HSI) 是可以的。
|
|