智能车制作
标题:
望各位大侠指点一下小弟的程序
[打印本页]
作者:
zzzmmmxxx
时间:
2011-4-19 22:34
标题:
望各位大侠指点一下小弟的程序
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
int num;
void initPIT(void)//定时中断初始化函数 50MS定时中断设置
{
PITCFLMT_PITE=0; //定时中断通道0关
PITCE_PCE0=1; //定时器通道0使能
PITMTLD0=240-1; //8位定时器初值设定。240分频,在24MHzBusClock下,为0.1MHz。即10us.
PITLD0=310-1; //16位定时器初值设定。PITTIME*0.01MS,1ms读取一次ATD_value
PITINTE_PINTE0=1; //定时器中断通道0中断使能
PITCFLMT_PITE=1; //定时器通道0使能
}
void PIT1S(void)
{
if(num==100)
{
PORTA=~PORTA;
num=0;
}
}
void main(void)
{ EnableInterrupts;
initPIT();
//DDRB=0XFF;
//DDRE=0X70;
DDRA=0XFF;
PORTA=0X00;
for(;;) {} /* wait forever */
/* please make sure that you never leave this function */
}
void interrupt 66 PIT0(void)
{
num++;
PIT1S();
PITTF_PTF0=1;
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED //指示该程序在不分页区
为什么A口的指示灯要过很久才一闪一闪,出现像
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2