Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] serial communication with ATMEGA32 problem

Status
Not open for further replies.

ANS HAFEEZ

Advanced Member level 4
Full Member level 1
Joined
Jul 25, 2013
Messages
101
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
LAHORE,PAKISTAN
Visit site
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:

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top