#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
/****************************************************************
8个LED灯的位码
****************************************************************/
unsigned char led_7[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char position[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char time[3];
unsigned char dis_buff[6];
unsigned char time_counter;
sbit point_on=0;
/**********************************************
延时函数
**********************************************/
void delay_us(unsigned int delay_counter)//延时1us
{
do
{
delay_counter--;
}
while(delay_counter>1);
}
void delay_ms(unsigned int delay_counter)//延时1ms
{
while(delay_counter!=0)
{
delay_us(1000);
delay_counter--;
}
}
/**********************************************
显示函数
**********************************************/
void display(void)
{
unsigned char i ;
for(i=0;i<=5;i++)
{
PORTA =led_7[dis_buff[i]];
if(point_on&&(i==2 || i==4))PORTA |=0x80;
PORTC = position[i];
delay_us(2);
PORTC = 0xff;
}
}
void time_to_disbuffer(void)
{
unsigned char i,j=0;
for(i=0;i<=2;i++)
{
dis_buff[j++] = time[i]%10;
dis_buff[j++] = time[i]/10;
}
}
/*********************************************
主程序
*********************************************/
void main(void)
{
PORTA = 0x00;
DDRA = 0xFF;
PORTC =0X3F;
DDRC = 0x3f;
time[2] = 23; time[1] = 58; time[0] =55;
time_to_disbuffer();
while(1)
{
delay_ms(2);
for(++time_counter >=40)
{
time_counter =0 ;
point_on = ~point_on;
if(++time[0] >=60)
{
time[0] =0;
if(++time[1] >= 60)
{
time[1] =0;
if(++time[2] >= 24) time[2] = 0;
}
}
time_to_disbuffer();
}
delay_us(13);
};
编译提示出错信息,本人是刚接触avr的超级鸟蛋,希望各位大哥指点下
Compiling C: main.c
avr-gcc -c -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=obj/main.lst -std=gnu99 -Wundef -MD -MP -MF .dep/main.o.d main.c -o obj/main.o
In file included from main.c:3:
D:/program file/WinAVR开发环境/avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete. Use <avr/interrupt.h>."
main.c:15: error: syntax error before "point_on"
main.c:15: warning: type defaults to `int' in declaration of `point_on'
main.c:15: warning: data definition has no type or storage class
main.c:69: warning: return type of 'main' is not `int'
main.c: In function `main':
main.c:81: error: syntax error before ')' token
main.c: At top level:
main.c:98: error: syntax error before '}' token
main.c:98:2: warning: no newline at end of file
make.exe: *** [obj/main.o] Error 1
> Process Exit Code: 2
> Time Taken: 00:01
} |