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.

cannot implement UART in ATMEGA16.

Status
Not open for further replies.

shashankshanky

Newbie level 3
Joined
Apr 14, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
hi all,
i want to receive the data from the hyperterminal and set PORT A high. however no data was transferred. i also tried receiving the data from the micro-controller. Even this was not working.
Later, i tried to simulate the same using the protheus designing software. still no response. tired of these, i tried simulating the sample code available in the data sheet. i even set the required bits to zero for asynchronous operation. all my efforts are wasted. i dont know where i am going wrong. please help me solve my problem .


c code:

#include<avr/io.h>

#define FOSC 1843200// Clock Speed
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1


void USART_Init( unsigned int ubrr)
{
/* Set baud rate */
UBRRH = (unsigned char)(ubrr>>8);
UBRRL = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
UCSRC = (0<<URSEL)|(0<<USBS)|(3<<UCSZ0);
}

unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) )
;
/* Get and return received data from buffer */
return UDR;
}
void USART_Transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) )
;
/* Put data into buffer, sends the data */
UDR = data;
}

int main( void )
{
DDRA=0B11111111;
int i;
unsigned char recdata';
USART_Init ( MYUBRR );
for(i=0;i<10;i++)
{
recdata=USART_Receive();


PORTA=0B11111111;
}

}


i tried everything. only problem i get is during the data (transmission or receiving). neither data is being received nor transmitted .I tried simulating everything in proteus designing software. still no solution. please help me
 

first try some most usual frequency such as 8MHZ or something like that. Secondly try the communication to simple 8bit no parity 1 bit for stopping.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top