[SOLVED] serial communication with ATMEGA32 problem

Status
Not open for further replies.

ANS HAFEEZ

Advanced Member level 4
Joined
Jul 25, 2013
Messages
101
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
LAHORE,PAKISTAN
Activity points
1,911
SALAM
i am using a C# programme which reads a file and send a string of data to ATMEGA32 via serial port .
for checking purpose i put the incoming data to portA.
as ATMEGA32 recieves data all pins of portA become at logic 1 no matter what kind of data is coming or
if i send different data ...
any tip about programming for ATMEGA32 my code is here

Code:
#include <avr/io.h>
# define F_CPU 16000000UL

void INIT_USART(void)
{
	UCSRB = (1<<RXEN);
	UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
	UBRRL = 103;
	UBRRH = (103>>8);
}

char USARTReadChar()
{
	while(!(UCSRA & (1<<RXC))){}
	return UDR;
}

int main()
{
	char data;
        INIT_USART();
	DDRB=0xFF;	
        while(1)
	{
		
		data = USARTReadChar();
		PORTB=data;	
	}
}
 
Last edited by a moderator:

You can use array to receive data
Till the string terminates
 

Code:
char inData[]="",i;
while(inData[i] = '\0')
{
	inData[i] = USART_receive();	
	i++;
}
 

Now in proteus Simulation works but when i apply this to hardware again the problem is same
i thnk i have some problem in fuse bits for external clock
 

if there is problem in Fuse bits you can go ahead with "AVR Burn-oMat" Software to change the fuse bit

Otherwise I would like to say that you first try to receive a character instead of string
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…