智能车制作
标题:
飞思卡尔双核单片机的超频源代码及注释(XS128)
[打印本页]
作者:
chiusir
时间:
2009-3-12 12:00
标题:
飞思卡尔双核单片机的超频源代码及注释(XS128)
本帖最后由 chiusir 于 2009-4-21 11:10 编辑
**************************************************************************************
龙丘智能车综合开发平台V3.0
Designed by 龙丘
E-mail:chiusir@163.com
软件版本:V1.2
最后更新:2009年4月21日
相关信息参考下列地址:
博客:
http://longqiu.21ic.org
淘宝店:
http://shop36265907.taobao.com
------------------------------------
Code Warrior 5.0
Target : MC9S12XS128
Crystal: 16.000Mhz
============================================
本程序主要包括以下功能:
1.设定系统工作在xxMHZ bus clock时钟下;
2.测试龙丘最小系统开发板超频性能:
如果LED闪烁,说明芯片正常工作;
否则,说明芯片没有正常工作,请检查系统设计;
3.也可以测试清华大学最小系统板的超频性能,
LED计数,根据灯亮可以读取系统循环了多少次
*****************************************************************************************/
#i nclude <hidef.h> /* common defines and macros */
#i nclude <MC9S12XS128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
void delayms(int ms)
{
int ii,jj;
if (ms<1) ms=1;
for(ii=0;ii<ms;ii++)
for(jj=0;jj<3338;jj++); //40MHz--1ms
}
void SetBusCLK_16M(void)
{
CLKSEL=0X00; // disengage PLL to system
PLLCTL_PLLON=1; // turn on PLL
SYNR=0x00 | 0x01; // VCOFRQ[7:6];SYNDIV[5:0]
// fVCO= 2*fOSC*(SYNDIV + 1)/(REFDIV + 1)
// fPLL= fVCO/(2 × POSTDIV)
// fBUS= fPLL/2
// VCOCLK Frequency Ranges VCOFRQ[7:6]
// 32MHz <= fVCO <= 48MHz 00
// 48MHz < fVCO <= 80MHz 01
// Reserved 10
// 80MHz < fVCO <= 120MHz 11
REFDV=0x80 | 0x01; // REFFRQ[7:6];REFDIV[5:0]
// fREF=fOSC/(REFDIV + 1)
// REFCLK Frequency Ranges REFFRQ[7:6]
// 1MHz <= fREF <= 2MHz 00
// 2MHz < fREF <= 6MHz 01
// 6MHz < fREF <= 12MHz 10
// fREF > 12MHz 11
// pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;
POSTDIV=0x00; // 4:0, fPLL= fVCO/(2xPOSTDIV)
// If POSTDIV = $00 then fPLL is identical to fVCO (divide by one).
_asm(nop); // BUS CLOCK=16M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_32M(void)
{
CLKSEL=0X00; // disengage PLL to system
PLLCTL_PLLON=1; // turn on PLL
SYNR =0x40 | 0x03; // pllclock=2*osc*(1+SYNR)/(1+REFDV)=64MHz;
REFDV=0x80 | 0x01;
POSTDIV=0x00;
_asm(nop); // BUS CLOCK=32M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_40M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x04;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=80MHz;
_asm(nop); //BUS CLOCK=40M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_48M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x05;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=96MHz;
_asm(nop); //BUS CLOCK=48M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_64M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x07;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=128MHz;
_asm(nop); //BUS CLOCK=64M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_80M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x09;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=160MHz;
_asm(nop); //BUS CLOCK=80M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_88M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x0a;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=176MHz;
_asm(nop); //BUS CLOCK=88M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_96M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x0b;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=192MHz;
_asm(nop); //BUS CLOCK=96M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_104M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x0c;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=208MHz;
_asm(nop); //BUS CLOCK=104M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void SetBusCLK_120M(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR =0xc0 | 0x0d;
REFDV=0x80 | 0x01;
POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=240MHz;
_asm(nop); //BUS CLOCK=120M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void main(void) {
/* put your own code here */
unsigned char LedCnt=0;
SetBusCLK_96M(); // 此处选择待设定的总线频率
DDRB=0xff;
DDRA=0x01;
PORTA=0XFE;
PORTB=0XFE;
EnableInterrupts;
for(;;) {
LedCnt=(LedCnt>0XFE?0:++LedCnt);
delayms(500); // 修改延时以修改数据发送频率
//低电平灯亮用这句,注释掉下面那句
PORTB=~LedCnt; // 测试清华版系统板
PORTA_PA0=~PORTA_PA0; // 测试龙丘最小系统板
//PORTB_BIT7=~PORTB_BIT7;
//高电平灯亮用这句,注释掉上面那句
//PORTB=LedCnt;
} /* wait forever */
/* please make sure that you never leave this */
}
完整工程:[attach]246[/attach]/
作者:
chiusir
时间:
2009-3-15 23:31
大家好好看看这个,应该都会用到的!
作者:
wsyn470
时间:
2009-3-27 23:33
ding
作者:
lynd323
时间:
2009-4-11 18:49
hao dongxi !
作者:
blojack
时间:
2009-4-19 23:13
终于有需要了。。。谢谢
作者:
chiusir
时间:
2009-4-21 11:11
源代码已经更新,龙丘的板子超频到96M很稳定!
作者:
江山
时间:
2009-4-21 17:31
THANK YOU
作者:
quote
时间:
2009-5-6 19:42
HAO DONG XI,HEHE!
作者:
fullerlinux
时间:
2009-5-14 00:27
好东西,顶下!!!
作者:
dkmy
时间:
2010-3-2 14:08
最大能超频到多大啊?
作者:
lxiongh
时间:
2010-3-4 10:47
正要测试超频,谢谢。
作者:
shirley_06
时间:
2010-4-14 13:36
谢谢LZ
作者:
cim
时间:
2010-4-15 02:22
回复
2#
chiusir
谢谢
作者:
dudu622
时间:
2010-4-15 08:43
谢啦
作者:
luson1321
时间:
2010-4-17 20:54
顶上去
作者:
huachou
时间:
2010-4-18 15:12
顶 太好了
作者:
huachou
时间:
2010-4-18 16:23
真好啊 基本上看了一遍了 感谢啊
作者:
cim
时间:
2010-5-1 19:59
谢谢
作者:
myb396
时间:
2010-5-4 11:07
请教
1、为什么要用“|”?
SYNR =0xc0 | 0x0d;
REFDV=0x80 | 0x01;
2、为什么要加下面两行?
_asm(nop); //BUS CLOCK=120M
_asm(nop);
作者:
myb396
时间:
2010-5-4 11:07
请教
1、为什么要用“|”?
SYNR =0xc0 | 0x0d;
REFDV=0x80 | 0x01;
2、为什么要加下面两行?
_asm(nop); //BUS CLOCK=120M
_asm(nop);
作者:
chiusir
时间:
2011-5-17 10:07
请教
1、为什么要用“|”?
SYNR =0xc0 | 0x0d;
REFDV=0x80 | 0x01;
2、为什么 ...
myb396 发表于 2010-5-4 11:07
用|是为了后续修改更方便,只需要修改后面部分即可;
asm是用做短暂的CPU空运行,等待锁相环稳定。
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2