我按照网上找到的程序打如下,我用CVAVR编译时出现错误: function return type 'int' doesn't match its previous declaration: 'unsigned char' from line: 33,提示我没有返回值吗?想知道哪里出错
#include <mega16.h>
#include <stdlib.h >
#include <delay.h>
void task1(void) // 左移循环 2轮
{
unsigned char position,i;
position = 0;
i = 16;
while(i--)
{
PORTA = ~(0x80 >> position);
if(++position >= 8)
position = 0;
delay_ms(500);
}
PORTA=0xFF;
}void task2(void) //右移循环 2轮
{
unsigned char position,i;
position = 0;
i = 16;
while(i--)
{
PORTA = ~(1 << position);
if(++position >= 8)
position = 0;
delay_ms(500);
}
PORTA=0xFF;
}void task3(void) //间隔点亮,明暗交替
{
bit position;
unsigned char i;
position = 1;
i = 16;
while(i--)
{
if(position )
{
PORTA = 0b10101010;
}
else
{
PORTA = 0b01010101;
}
position = !position;
delay_ms(500);
}
PORTA=0xFF;
}void task4(void) // 随机点亮
{
unsigned char i;
i = 16;
while(i--)
{
PORTA = (unsigned char)rand();
delay_ms(500);
}
PORTA=0xFF;
} void main(void) //主函数
{
PORTA=0xFF;
DDRA=0xFF;
while (1)
{
task1(); delay_ms(500);
task2(); delay_ms(500);
task3(); delay_ms(500);
task4(); delay_ms(500);
};
} |