飞思卡尔单片机求救
时间:10-02
整理:3721RD
点击:
#include <mc9s12xs128.h>
#include "derivative.h"
void main (void)
{
char a;
DDRA=0xFF;
a = 0;
while(1)
{
PORTA = 0x00;
switch (a)
{
case 0:
PORTA = 0x01;
case 1:
PORTA = 0x02;
case 2:
PORTA = 0x04;
case 3:
PORTA = 0x08;
case 4:
PORTA = 0x10;
case 5:
PORTA = 0x20;
case 6:
PORTA = 0x40;
case 7:
PORTA = 0x80;
default:PORTA = 0x00
}
a+1;
if(a = 8);
{
a=0;
};
delay(200);
}
}
错误如下:default后面的那个大括号丢失分号
delay后丢失分号
结束错误
怎么改?
#include "derivative.h"
void main (void)
{
char a;
DDRA=0xFF;
a = 0;
while(1)
{
PORTA = 0x00;
switch (a)
{
case 0:
PORTA = 0x01;
case 1:
PORTA = 0x02;
case 2:
PORTA = 0x04;
case 3:
PORTA = 0x08;
case 4:
PORTA = 0x10;
case 5:
PORTA = 0x20;
case 6:
PORTA = 0x40;
case 7:
PORTA = 0x80;
default:PORTA = 0x00
}
a+1;
if(a = 8);
{
a=0;
};
delay(200);
}
}
错误如下:default后面的那个大括号丢失分号
delay后丢失分号
结束错误
怎么改?
a+1改为a++;去掉if();后面的分号,if的大括号后的分号也可去掉,a=8,改为a==8,delay函数未声明、未定义
还有就是default后面少了分号
brank了?你的流水灯程序质量太差。