发布网友 发布时间:2022-04-26 07:21
共2个回答
热心网友 时间:2022-06-25 05:18
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int counter;
void TimerOverflow(void) {
/* This function waits for th timer overflow.
Then it changes the LEDs bargraph display */
while (TCNT != 0x0000);
while (TCNT == 0x0000);
counter++;
if (counter == 8) PORTB = 0x7e; /* LEDs' lightshow */
if (counter == 7) PORTB = 0xbd;
if (counter == 6) PORTB = 0xdb;
if (counter == 5) PORTB = 0xe7;
if (counter == 4) PORTB = 0xe7;
if (counter == 3) PORTB = 0xdb;
if (counter == 2) PORTB = 0xbd;
if (counter == 1) PORTB = 0x7e;
}
void main(void)
{
TSCR1 = 0x80; /* enable timer TCNT */
TSCR2 = 0x03; /* TCNT prescaler setup */
counter = 0;
DDRB=0xff; /* PTB as output */
PORTB=0xff; /* LEDs off */
asm{
nop
}
for (;;)
{
TimerOverflow();
if (counter >= 8) {
counter = 0;
TSCR2 = 0x05; /* TCNT prescaler switch */
}
}
}
热心网友 时间:2022-06-25 05:18
上面的是什么程序啊,我编译了错了好多!!!!!!!