Getting Unknown variable error while compiling c to hex

The  following  code  is  for  gps  gsm  module.The  compiled  hex  code  is  pushed  to  microprocessor.
While  compiling the  below code  we  get  unknown  variable  error  for  following  variables UCZS0, UCZS1
Please  guide  us  for  same.

//GPS and GSM Based Vehicle tracking system
#define F_CPU 12000000			//12Mhz
#include <avr/io.h>			//Header file for AVR device specific I/O Definitions.
#include <avr/pgmspace.h>		//Header file for incorporating program space string utilities.
#include <util/delay.h>			//Header file for incorporating delay routines.
#include<inttypes.h>


#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

void WaitMs(unsigned int ms);		

void usart_init();
unsigned int usart_getch();
void usart_writech(unsigned char data);
void usart_message(unsigned char *var);

unsigned char value,i,lati_value[9],lati_dir, longi_value[10], longi_dir, final_message[30];
unsigned char deg = 0xB0;

int main()
{

DDRC=0x00;
PORTC=0xff;

    usart_init();

    while(1)
	{
	 a:
	 value=usart_getch();
	 if(value=='$')
	 {
		
	value=usart_getch();
		if(value=='G')
	{
	value=usart_getch();
	if(value=='P')
	{
	value=usart_getch();
	if(value=='G')
	{
				
	value=usart_getch();
	if(value=='A')
	{
	value=usart_getch();
	if(value==',')
	{
	value=usart_getch();
	while(value!=',')
	{
	value=usart_getch();
	}
	
	for(i=0; i<9; i++)
	{

	lati_value[i] = usart_getch();

	}
	value = usart_getch();
	
	lati_dir=usart_getch();
	value=usart_getch();
	for(i=0; i<10; i++)
	{

	longi_value[i] = usart_getch();
	}
    value = usart_getch();
	
		for(i=1;value!=',';i++)
	{
		longi_value[i]=usart_getch();

		value=longi_value[i];
		}
	longi_dir=usart_getch();
	}
	}
	}
	}
	}
	}
	if(*lati_value && *longi_value)
	{
     for(i=0; i<9; i++)
	 {
	 final_message[i] = lati_value[i];

	  }

  final_message[9] = lati_dir;
  final_message[10] = ' ';
	 for(i=0; i<10; i++)
	 {

	 final_message[i+11] = longi_value[i];
  }

	
	final_message[21] = longi_dir;
	 final_message[22] = '\0';
    }
	else
	 goto a;
	while(PINC==0xff);
     WaitMs(1000);
	 usart_message("ATH");
	 WaitMs(50);

       
	 usart_message("AT+CMGF=1");
	 usart_writech(0x0D);
	 WaitMs(20);
		 
	WaitMs(20);
	usart_message("AT+CMGS=\"+918907607614\"");
	 usart_writech(0x0D);
	 usart_message(final_message);//message
	 usart_writech(0x1A);
	 WaitMs(10000);
		 goto a;
	 
    }


	return 0;	
	
}


void WaitMs(unsigned int ms)		
{
	unsigned int i;

	for(i=0;i<=ms;i++)
	{
		_delay_ms(1);
	}
}


 
void usart_init()
{

UCSRB =  (1 << RXEN) | (1 << TXEN);                    

// Use 8-bit character sizes
UCSRC |= (1 << URSEL) | (1 << UCZS0) | (1 << UCZS1);   

// Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRL = BAUD_PRESCALE;  
                              
UBRRH = (BAUD_PRESCALE >> 8);                          
}
 
 
unsigned int usart_getch()
{

while (!(UCSRA & (1 << RXC)));                          

return(UDR);                                            
}

void usart_writech(unsigned char data)
{
 
 while(!(UCSRA & (1<<UDRE)));
 UDR = data;
}

void usart_message(unsigned char *var) 
{
int h;
while(*var)         
usart_writech(var++); // send message
for(h=0;h<=200;h++); 
}

Open in new window

ADITYA RAOSoftware DeveloperAsked:
Who is Participating?
 
sarabandeConnect With a Mentor Commented:
we  get  unknown  variable  error  for  following  variables UCZS0, UCZS1

is there still an error if you add statements

#define UCZS0 0
#define UCZS1 1

below include statements? if yes, you should search all header files for a definition of those constants and include the header file if you found one.

while (!(UCSRA & (1 << RXC)));

how do you want to break from this loop if the condition is true? neither UCSRA nor RXC will change in that loop.

if the UCSRA and/or RXC are shared variables which might be modified in a second thread, you might need the volatile keyword for the definition in order that the compiler adds statements to recognize such changes. anyway, the loop is bad programming and may push one core of your cpu's to 100 %.

you have same kind of loop a multiple time.

Sara
0
 
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
Severity	Code	Description	Project	File	Line	Suppression State
Error	C1083	Cannot open include file: 'avr/io.h': No such file or directory	ConsoleApplication3	g:\documents\visual studio 2017\projects\consoleapplication3\consoleapplication3\consoleapplication3.cpp	6	
Error (active)	E0167	argument of type "const char *" is incompatible with parameter of type "unsigned char *"	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	122	
Error (active)	E0167	argument of type "const char *" is incompatible with parameter of type "unsigned char *"	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	126	
Error (active)	E0167	argument of type "const char *" is incompatible with parameter of type "unsigned char *"	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	131	
Error (active)	E0020	identifier "_delay_ms" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	152	
Error (active)	E0020	identifier "UCSRB" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	161	
Error (active)	E0020	identifier "RXEN" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	161	
Error (active)	E0020	identifier "TXEN" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	161	
Error (active)	E0020	identifier "UCSRC" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	164	
Error (active)	E0020	identifier "URSEL" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	164	
Error (active)	E0020	identifier "UCZS0" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	164	
Error (active)	E0020	identifier "UCZS1" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	164	
Error (active)	E0020	identifier "UBRRL" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	167	
Error (active)	E0020	identifier "UBRRH" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	169	
Error (active)	E0020	identifier "UCSRA" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	176	
Error (active)	E0020	identifier "RXC" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	176	
Error (active)	E0020	identifier "UDR" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	178	
Error (active)	E0020	identifier "UCSRA" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	184	
Error (active)	E0020	identifier "UDRE" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	184	
Error (active)	E0020	identifier "UDR" is undefined	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	185	
Error (active)	E0167	argument of type "unsigned char *" is incompatible with parameter of type "unsigned char"	ConsoleApplication3	g:\Documents\Visual Studio 2017\Projects\ConsoleApplication3\ConsoleApplication3\ConsoleApplication3.cpp	192	

Open in new window


Where are these variables defined?  in one of the #includes ????
unsigned int usart_getch()
{

	while (!(UCSRA & (1 << RXC)));

	return(UDR);
}

Open in new window

0
 
ADITYA RAOSoftware DeveloperAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.