'Undefined refrence to main error' in winavr gcc compiler????
Hi,I am new in compiling programs for microcontrollers...My program gives a undefined reference to main error when done in avr studio 4.15 ysing winavr gcc compiler in ATmega8L.....
This is my program
# include <avr/io.h>
/*
PROGRAM FOR MULTIPLE NUMBER LOCK USING ATmega8.
************************************************************
Function for displaying a digit
*/
void display(int y)
{
if(y==0)
PORTB=0xC0;
else if(y==1)
PORTB=0x79;
else if(y==2)
PORTB=0x24;
else if(y==3)
PORTB=0x30;
else if(y==4)
PORTB=0x19;
else if(y==5)
PORTB=0x12;
else if(y==6)
PORTB=0x02;
else if(y==7)
PORTB=0x78;
else if(y==8)
PORTB=0x00;
else if(y==9)
PORTB=0x10;
else if(y==10)
PORTB=0x3F;
else if(y==11)
PORTB=0x7E;
}
/*
Function to detect a key from key board
*/
int keydetect(void)
{
unsigned char i,y,z;
int dgt=15;
while(dgt==15)
{
int k=0;
y=0x00;
PORTD=0x02;
while(y==0x00)
{
k=0;
i=PIND;
y=(i&0xE0);
if(PORTD==0x10)
{
k=1;
PORTD=0x01;
}
PORTD=(PORTD*0x02);
}
if(k!=1)
PORTD=PORTD/0x02;
else
PORTD=0x10;
z=PORTD;
if(z==0x02)
{
if(y==0x20)
dgt=1;
else if(y==0x40)
dgt=2;
else if(y==0x80)
dgt=3;
}
else if(z==0x04)
{
if(y==0x20)
dgt=4;
else if(y==0x40)
dgt=5;
else if(y==0x80)
dgt=6;
}
else if(z==0x08)
{
if(y==0x20)
dgt=7;
else if(y==0x40)
dgt=8;
else if(y==0x80)
dgt=9;
}
else if(z==0x10)
{
if(y==0x20)
dgt=10;
else if(y==0x40)
dgt=0;
else if(y==0x80)
dgt=11;
}
display(dgt);
while((PIND&0xE0)!=0);
}
return(dgt);
}
/*
Delay function
*/
void delay(int y)
{
int x,z;
for(x=0;x<y;x++)
{
for(z=0;z<30000;z++);
}
}
/*
Function to check a password
*/
int check(int y)
{
int x[3],i,j,e;
int p[3]={5,5,5};
int p2[3]={2,3,4};
int p3[3]={3,4,5};
int p4[3]={4,5,6};
int p5[3]={5,6,7};
int p6[3]={6,7,8};
PORTB=0x0C;
for(i=0;i<3;i++)
{
x[i]=keydetect();
PORTB=0x77;
for(j=0;j<1000;j++);
}
PORTB=0x7E;
e=0;
while(e!=10)
e=keydetect();
j=0;
if(y==0)
{
for(i=0;i<3;i++)
{
if(x[i]!=p[i])
j=1;
}
}
else if(y==1)
{
for(i=0;i<3;i++)
{
if(x[i]!=p1[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x01);
delay(2000);
}
}
else if(y==2)
{
for(i=0;i<3;i++)
{
if(x[i]!=p2[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x02);
delay(2000);
}
}
else if(y==3)
{
for(i=0;i<3;i++)
{
if(x[i]!=p3[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x04);
delay(2000);
}
}
else if(y==4)
{
for(i=0;i<3;i++)
{
if(x[i]!=p4[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x08);
delay(2000);
}
}
else if(y==5)
{
for(i=0;i<3;i++)
{
if(x[i]!=p5[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x10);
delay(2000);
}
}
else if(y==6)
{
for(i=0;i<3;i++)
{
if(x[i]!=p6[i])
j=1;
}
if(j==0)
{
PORTB=0x08;
PORTC=(PORTC^0x20);
delay(2000);
}
}
return(j);
}
/*
The main function
*/
int main(void)
{
DDRD=0x1E;
DDRB=0xFF;
DDRC=0x7F;
int y,i,j,e;
while(1)
{
i=check(0);
while(i==0)
{
PORTB=0x2B;
y=keydetect();
display(y);
e=0;
while(e!=10)
e=keydetect();
j=check(y);
if(j==1)
{
PORTB=0X86;
e=0;
while(e!=11)
e=keydetect();
}
}
}
return(1);
}
This my miniproject program......Any help on ports will be given....
|