智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 5829|回复: 12
打印 上一主题 下一主题

[单片机] 单片机超频是与硬件系统的外部晶振源有关的吧

[复制链接]

3

主题

48

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
307
QQ
威望
266
贡献
21
兑换币
0
注册时间
2010-3-22
在线时间
10 小时
跳转到指定楼层
1#
发表于 2010-4-17 19:13:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1贡献
很多人都在找相关超频的代码,但是我想,这个还与自身的外部晶振源有关的吧,比如说,我的外部晶振是16M的,那么,我还能用PLL超到80M吗??

最佳答案

查看完整内容

超频代码 #include /* common defines and macros */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12xs128" void delayms(int ms) { int ii,jj; if (ms

30

主题

477

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
4940

论坛元老奖章

威望
705
贡献
4087
兑换币
0
注册时间
2009-6-14
在线时间
74 小时
2#
发表于 2010-4-17 19:13:17 | 只看该作者
超频代码

#include <hidef.h>      /* common defines and macros */
#include <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;
}
回复

使用道具 举报

2

主题

25

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
327
威望
282
贡献
31
兑换币
10
注册时间
2010-1-13
在线时间
7 小时
3#
发表于 2010-4-17 19:50:04 | 只看该作者
可以的,我们的另外一队就超到了80M!
回复

使用道具 举报

2

主题

25

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
327
威望
282
贡献
31
兑换币
10
注册时间
2010-1-13
在线时间
7 小时
4#
发表于 2010-4-17 19:51:10 | 只看该作者
不信你超频,但是可能会死机,就是单片机死机
回复

使用道具 举报

3

主题

48

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
307
QQ
威望
266
贡献
21
兑换币
0
注册时间
2010-3-22
在线时间
10 小时
5#
 楼主| 发表于 2010-4-17 21:06:46 | 只看该作者
回复 3# 我的A计划
但是PLL计算的时候,公式里有个OSC,这个值是什么呢
回复

使用道具 举报

30

主题

477

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
4940

论坛元老奖章

威望
705
贡献
4087
兑换币
0
注册时间
2009-6-14
在线时间
74 小时
6#
发表于 2010-4-18 19:29:25 | 只看该作者
如果你的板子可以超频到96M建议使用80m,一次类推
回复

使用道具 举报

3

主题

48

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
307
QQ
威望
266
贡献
21
兑换币
0
注册时间
2010-3-22
在线时间
10 小时
7#
 楼主| 发表于 2010-4-19 23:31:18 | 只看该作者
如果你的板子可以超频到96M建议使用80m,一次类推
王怀玉 发表于 2010-4-18 19:29


再菜菜的问一下,计算PLL频率的时候,公式里用到的OSC 是系统板上的外部晶振大小吗??
回复

使用道具 举报

30

主题

477

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
4940

论坛元老奖章

威望
705
贡献
4087
兑换币
0
注册时间
2009-6-14
在线时间
74 小时
8#
发表于 2010-4-20 18:52:01 | 只看该作者
回复 7# junjianjunjian


    不清楚
回复

使用道具 举报

0

主题

42

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
250
QQ
威望
212
贡献
20
兑换币
0
注册时间
2008-12-22
在线时间
9 小时
9#
发表于 2010-5-8 14:41:27 | 只看该作者
学习了
回复

使用道具 举报

3

主题

115

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1103
QQ
威望
686
贡献
221
兑换币
70
注册时间
2010-6-9
在线时间
98 小时
10#
发表于 2010-6-29 07:57:14 | 只看该作者
不懂
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关于我们|联系我们|小黑屋|智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-9-20 20:32 , Processed in 0.427011 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表