Sign In

Errors On Debugging Program

Harsha Vardhan Reddy harsha.reddy.100483@gmail.com India

Hardware: ATmega32 Working On 16MHZ Software: C Programing Using AVR Studio 5

error showing "undefined reference to 'main' ".

Images

Program

#include<avr/io.h>
#include<util/delay.h>

#include "lcd.h"

#define F_CPU  16000000;
#define lcd_data  PORTB
#define lcd_cont PORTD
#define lcd_rs  PD0
#define lcd_rw  PD1
#define lcd_en  PD2
#define ADC_DATA_PORT PA1

main()
void InitADC()
{
 ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);	
}	
uint16_t ReadADC(uint8_t ch)
{
 ch=ch&0b00000111;
 ADMUX|=ch;
 ADCSRA|=(1<<ADSC);
 while(!(ADCSRA&(1<<ADIF)));
 ADCSRA|=(1<<ADIF);
 return (ADC);	
}
void wait()
{
	uint8_t i;
	for(i=0;i<20;i++)
	_delay_loop_2(0);
}	
void LCD_cmd(unsigned char cmd);
void Init_lcd(void);
void LCD_write(unsigned char data);

int main(void)
{
	DDRB=oxFF;
	DDRD=oxEo;
	Init_lcd();
	LCD_cmd(oxoC);
	uint16_t adc_result;
	InitADC();
        LCD_write("ADC Test")
	LCD_write("ADC=")
	while(1)
	{
		adc_result=ReadADC(0);
		LCD_write(4,1,"adc_result,4")
		wait();
	}		
}	 

Replies

R Avinash
2016-05-18 11:21:21
remove the line 14 where you have written main(). above void InitADC()

Also the hexadecimal literals are preceded by 0x and not ox (the first is zero and you have written o for orange)!

I feel pity for peoples who don't know anything about C language and jump everywhere
R Avra Mitra
2016-05-20 04:55:53
you made a lot of mistakes. please read some books on C.
#include<avr/io.h>
#include<util/delay.h>

#include "lcd.h"

#define F_CPU  16000000 //you wrote "#define F_CPU  16000000;"
#define lcd_data  PORTB
#define lcd_cont PORTD
#define lcd_rs  PD0
#define lcd_rw  PD1
#define lcd_en  PD2
#define ADC_DATA_PORT PA1

//main()  <<------this shouldn't be here
void InitADC()
{
 ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);	
}	
uint16_t ReadADC(uint8_t ch)
{
 ch=ch&0b00000111;
 ADMUX|=ch;
 ADCSRA|=(1<<ADSC);
 while(!(ADCSRA&(1<<ADIF)));
 ADCSRA|=(1<<ADIF);
 return (ADC);	
}
void wait()
{
	uint8_t i;
	for(i=0;i<20;i++)
	_delay_loop_2(0);
}	
void LCD_cmd(unsigned char cmd);
void Init_lcd(void);  //u wrote void "Init lcd(void);"
void LCD_write(unsigned char data); //u wrote "void LCD write(unsigned char data);"

int main(void)
{
	DDRB=0xFF;  //you wrote "DDRB=oxFF;"
	DDRD=0xE0;   //you wrote "DDRB=oxEo;"
	Init_lcd();
	LCD_cmd(0x0C);  //you wrote "LCD_cmd(oxoC);"
	uint16_t adc_result;
	InitADC();
        LCD_write("ADC Test")
	LCD_write("ADC=")
	while(1)
	{
		adc_result=ReadADC(0);
		LCD_write(4,1,"adc_result,4")
		wait();
	}		
}
R Avra Mitra
2016-05-20 05:35:44
#include
#include

#include "lcd.h"

#define F_CPU 16000000 //you wrote "#define F_CPU 16000000;"
#define lcd_data PORTB
#define lcd_cont PORTD
#define lcd_rs PD0
#define lcd_rw PD1
#define lcd_en PD2
#define ADC_DATA_PORT PA1

//main() <<------this shouldn't be here
void InitADC()
{
ADCSRA=(1< }
uint16_t ReadADC(uint8_t ch)
{
ch=ch&0b00000111;
ADMUX|=ch;
ADCSRA|=(1< while(!(ADCSRA&(1< ADCSRA|=(1< return (ADC);
}
void wait()
{
uint8_t i;
for(i=0;i<20;i++)
_delay_loop_2(0);
}
void LCD_cmd(unsigned char cmd);
void Init_lcd(void); //u wrote void "Init lcd(void);"
void LCD_write(unsigned char data); //u wrote "void LCD write(unsigned char data);"

int main(void)
{
DDRB=0xFF; //you wrote "DDRB=oxFF;"
DDRD=0xE0; //you wrote "DDRB=oxEo;"
Init_lcd();
LCD_cmd(0x0C); //you wrote "LCD_cmd(oxoC);"
uint16_t adc_result;
InitADC();
LCD_write("ADC Test")
LCD_write("ADC=")
while(1)
{
adc_result=ReadADC(0);
LCD_write(4,1,"adc_result,4")
wait();
}
}

Post a reply to Harsha Vardhan Reddy

Think you can help Harsha Vardhan Reddy ? Then post your thoughts that might help Harsha Vardhan Reddy. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.