Click here to Skip to main content
15,884,018 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
usart.h

C++
#ifndef	_USART_H_
#define	_USART_H_ 	1



#include<io.h>
#include<delay.h>



/*The function is declared to initialize the USART with following cinfiguration:-
USART mode - Asynchronous
Baud rate - 9600
Data bits - 8
Stop bit - 1
Parity - No parity.*/

void usart_init();




/*The function is declared to transmit data.*/

void usart_data_transmit(unsigned char data );




/*The function is declared to receive data.*/

unsigned char usart_data_receive( void );




/*The function is declared to transmit string.*/

void usart_string_transmit(char *string);




/*The function is declared to receive string.*/

char *usart_string_receive(char *receive_string,unsigned char terminating_character);



/*Function defination*/

void usart_init()
{
UBRRH = 0;
UBRRL =51;
UCSRB|= (1<<RXEN)|(1<<TXEN);
UCSRC |= (1 << URSEL)|(3<<UCSZ0);
}


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

unsigned char usart_data_receive( void )
{
while ( !(UCSRA & (1<<RXC)) )
;
return UDR;
}

void usart_string_transmit(char *string)
{
while(*string)
{
usart_data_transmit(*string++);
}
}

char *usart_string_receive(char *receive_string,unsigned char terminating_character)
{
	unsignedchar temp=0x00;
	for(unsignedchar i=0;;i++)
	{
		*(receive_string+i)=usart_data_receive();
		if(*(receive_string+i)==terminating_character)
			break;
		else
		temp++;
	}
	*(receive_string+temp)='\0';
	return receive_string;
}
#endif


What I have tried:

Error: C:\cvavr\inc\usart.h(113): undefined symbol 'unsignedchar'
Error: C:\cvavr\inc\usart.h(114): undefined symbol 'unsignedchar'
Error: C:\cvavr\inc\usart.h(114): undefined symbol 'i'
Error: C:\cvavr\inc\usart.h(117): undefined symbol 'i'
Error: C:\cvavr\inc\usart.h(120): undefined symbol 'temp'
Error: C:\cvavr\inc\usart.h(122): undefined symbol 'temp'
Posted
Updated 27-Jun-16 14:33pm
Comments
shsmszdh 28-Jun-16 16:48pm    
thanks for your suggestion I did it and errors reduced to these: please help me
Error: C:\cvavreval\inc\usart.h(114), #include-d from: hc05.h: undefined symbol 'unsigned'
Error: C:\cvavreval\inc\usart.h(114), #include-d from: hc05.h: undefined symbol 'i'
Error: C:\cvavreval\inc\usart.h(117), #include-d from: hc05.h: undefined symbol 'i'
Error: C:\cvavreval\inc\hc05.h(67), #include-d from: hc1.c: undefined symbol 'unsigned'
Error: C:\cvavreval\inc\hc05.h(67), #include-d from: hc1.c: undefined symbol 'i'
Error: C:\cvavreval\inc\hc05.h(70), #include-d from: hc1.c: undefined symbol 'j'
Error: C:\cvavreval\inc\hc05.h(188), #include-d from: hc1.c: must declare first in block

1 solution

These errors
C++
Error: C:\cvavr\inc\usart.h(114): undefined symbol 'i'
Error: C:\cvavr\inc\usart.h(117): undefined symbol 'i'
Error: C:\cvavr\inc\usart.h(120): undefined symbol 'temp'
Error: C:\cvavr\inc\usart.h(122): undefined symbol 'temp' 

are the consequence of
C++
Error: C:\cvavr\inc\usart.h(113): undefined symbol 'unsignedchar'
Error: C:\cvavr\inc\usart.h(114): undefined symbol 'unsignedchar'

The compiler tells you that unsignedchar is unkown. You just have to find where you forgot the space.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900