中级会员
- 积分
- 320
- 威望
- 234
- 贡献
- 46
- 兑换币
- 10
- 注册时间
- 2008-10-19
- 在线时间
- 20 小时
|
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int duan[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
int i;
void SET_PLL(void)
{ REFDV=3;
SYNR=1;
while(CRGFLG_LOCK==0);
CLKSEL=0x80; //时钟初始化总线频率8MHz
}
void main(void)
{ EnableInterrupts;//开中断
SET_PLL();
TIOS=0X01;
//TIE=0X01;
DDRB=0xff; // PTB as output
TSCR1 = 0x80; // enable timer TCNT
TSCR2 = 0x87; // TCNT prescaler setup
PORTB=0x00; // LEDs off
TC0=0Xf424;
for (;;) {}
}
#pragma CODE_SEG NON_BANKED
void interrupt 16 TCNT_ISR(void)
{
DisableInterrupts; //关中断
PORTB=duan[i];
i++;
if(i>9)
i=0;
TFLG2=0x80;
EnableInterrupts
}
计时不准确,希望大家帮忙修改一下。 |
|