金牌会员
 
- 积分
- 1473

- 威望
- 745
- 贡献
- 386
- 兑换币
- 189
- 注册时间
- 2011-11-18
- 在线时间
- 171 小时
|
PWM0口就是不出波形,真的不知道为什么了! 求大侠们帮助啊!!!
/*------------------------------------------------------------------------*/
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative information */
//#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
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 PWM_init(void) //脉宽调制模块的初始化
{
//SB,B for ch2367
//SA,A for ch0145
PWME_PWME0=0X00;
PWMPRCLK=0X44; // 0100 0100 A=B=48M/16= 3M
PWMSCLA=150;
PWMSCLB=150; // SB=B/2/150=10K
PWMCLK_PCLK0=1; // PWM3---SB
PWMPOL_PPOL0=1; // duty = high time
PWMCAE_CAE0=0; // left-aligned
PWMCTL=0X00;
PWMPER0=100; // frequency = SB/100 = 100Hz 10ms
PWMDTY0=50; // duty cycle =
PWME_PWME0=1;
}
void main(void) {
/* put your own code here */
unsigned char LedCnt=0;
SetBusCLK_48M(); // 设定总线频率
PWM_init();
EnableInterrupts;
for(;;) {
} /* wait forever */
/* please make sure that you never leave this function */
}
|
|