注册会员
- 积分
- 146
- 威望
- 94
- 贡献
- 30
- 兑换币
- 34
- 注册时间
- 2014-6-20
- 在线时间
- 11 小时
- 毕业学校
- HIT
|
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "MC9S12XS128.h"
static unsigned char j = 0;
uchar LedChar[] = {0x3C,0x3C,0x3C,0x00,0x00,0x3C,0x3C,0x3C};
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 16 TOI_ISR(void)
{
TFLG2_TOF = 1;
PORTA = 0xff;
switch(j)
{
case 0: PORTB_PB5=0; PORTB_PB6=0; PORTB_PB7=0; break;
case 1: PORTB_PB5=1; PORTB_PB6=0; PORTB_PB7=0; break;
case 2: PORTB_PB5=0; PORTB_PB6=1; PORTB_PB7=0; break;
case 3: PORTB_PB5=1; PORTB_PB6=1; PORTB_PB7=0; break;
case 4: PORTB_PB5=0; PORTB_PB6=0; PORTB_PB7=1; break;
case 5: PORTB_PB5=1; PORTB_PB6=0; PORTB_PB7=1; break;
case 6: PORTB_PB5=0; PORTB_PB6=1; PORTB_PB7=1; break;
case 7: PORTB_PB5=1; PORTB_PB6=1; PORTB_PB7=1; break;
default: break;
}
PORTA=LedChar[j++];
}
#pragma CODE_SEG DEFAULT
void main(void) {
/* put your own code here */
TSCR1_TEN = 1; //中断使能
TSCR2_TOI = 1; //溢出中断允许
TC0 = 0xfacb; //赋初值,1ms
DDRB=0xff;
PORTB_PB4=1;
DDRA = 0xff;
PORTA = 0xff;
EnableInterrupts;
for(;;)
{
if(j>=8) j=0;
} /* loop forever */
/* please make sure that you never leave main */
}
|
|