新闻  |   论坛  |   博客  |   在线研讨会
Renesas单片机内部晶振、外部晶振设置
我就是我lxw | 2012-07-23 14:16:33    阅读:13399   发布文章

//外部晶振
void Clock_Init( void )
{
 /* Set fxh */
 uchar temp_stabset, temp_stabwait;
 OSTS = 0x05; /* 2^16/fx */
 OSCCTL = 0x40|0x01; /* X1, X2 as crystal/ceramic resonator connection */   /* 10 MHz < fxh <= 20 MHz */
 MSTOP = 0;
 temp_stabset = 0x1f; /* 2^16/fx */
 do{
  temp_stabwait = OSTC;
  temp_stabwait &= temp_stabset;
 }while(temp_stabwait != temp_stabset);
 /* Set fprs */
 MCM = 0x05; /* fxp = fxh,fprs = fxh */
 /* Set frh */
 RSTOP = 1;
 /* Set fsub */
 XTSTART = 0;
 /* Set fcpu */
 PCC &= (uchar)~(0x07 | 0x10);
 PCC |= 0x01; /* fcpu = fxp/2 (default) */
 /* Set frl */
 LSRSTOP = 0;
}

//内部晶振
void Clock_Init( void )
{
 /* Set fxh */
 OSCCTL = 0x00; /* X1, X2 as I/O port */
 MSTOP = 1;
 /* Set frh */
 RSTOP = 0;
 /* Set fprs */
 MCM = 0x00; /* fxp = frh,fprs = frh */
 /* Set fsub */
 XTSTART = 0;
 /* Set fcpu */
 PCC &= (uchar)~(0x07 | 0x10);
 PCC |= 0x01; /* fcpu = fxp/2 (default) */
 /* Set frl */
 LSRSTOP = 0;
}

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客