智能车制作
标题:
请各位学长帮忙看看哪里错了
[打印本页]
作者:
ytcx
时间:
2013-3-3 20:43
标题:
请各位学长帮忙看看哪里错了
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
//#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
unsigned char Data1[8]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F};
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 PIT_init(void)//定时中断初始化函数 5MS定时中断设置
{
PITCFLMT_PITE=0; //定时中断通道0关
PITCE_PCE0=1;//定时器通道0使能
PITMTLD0=64-1;//8位定时器初值设定,64分频,在64MHzBusClock下,为1MHz。即1us
PITLD0=1000-1;//16位定时器初值设定。PITTIME*0.125uS 即1ms中断一次
PITINTE_PINTE0=1;//定时器中断通道0中断使能
PITCFLMT_PITE=1;//定时器通道0使能
}
//void delay(int);
void main(void) {
unsigned char i;
i=0;
SetBusCLK_64M();
PIT_init();
while(1) {
DDRB=0xff;
PORTB=Data1[i];
}
}
void interrupt 66 PIT0(void){
int num,num2;
num++;
if(num>1999){
num=0;
num2++;
i++;
if(num2>7){
num2=0;
PORTB=0xff;
i=0;
}
}
}
作者:
音之夏萤
时间:
2013-3-4 15:59
至少你要说明一下出现什么问题了吧
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2