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.

Uart simmulation on proteus using atmega 32

Status
Not open for further replies.

belal elkady

Newbie level 6
Joined
Jun 4, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
EgYpT
Activity points
1,388
it's the first code in UART so i'm trying to simulate it and i use the virtual terminal on proteus

but nothing appear i don't know why ??

the code :
/*
* Uart_Driver.c
*
* Created: 7/29/2013 4:33:00 PM
* Author: Belak Magdy
*/


#include <avr/io.h>
void UARTinit();
void UARTsender(char data);
char UARTreceiver();


void UARTinit(){
UBRRH=0X03; // 1200 bps & 16MHZ clock frequency
UBRRL=0X41;
UCSRB|=(1<<RXEN)|(1<<TXEN);
UCSRC|=(1<<URSEL)|(3<<UCSZ0);
}

void UARTsender(char data){

while(!(UCSRA & (1<<UDRE))) {

}

UDR = data ;


}

char UARTreceiver(){

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

}

return UDR;


}


that's very simple app:
#include <avr/io.h>
#include <stdio.h>

void main (){
UARTinit();


while(1){
UARTsender("b");
UARTreceiver();
}

}

8-30-2013 2-20-31 PM.png
 

did you select the baudrate settings in virtual terminal and frequency in Chip??

then it must be the problem of

Code C - [expand]
1
while(!(UCSRA & (1<<UDRE))) {}




try to take this commanded if still not works check the config, then there is no uart in the library device..
 

did you select the baudrate settings in virtual terminal and frequency in Chip??

then it must be the problem of

Code C - [expand]
1
while(!(UCSRA & (1<<UDRE))) {}




try to take this commanded if still not works check the config, then there is no uart in the library device..

yes, i did and i don't find any problem in the code . please take a look at the simulation
 

Hi belal elkady
I haven't checked your baud rate and other settings yet But your UARTsender function expects a char and you are passing it a string
try changing

Code C - [expand]
1
UARTsender("b");


to

Code C - [expand]
1
UARTsender('b');

 
Hi belal elkady
I haven't checked your baud rate and other settings yet But your UARTsender function expects a char and you are passing it a string
try changing

Code C - [expand]
1
UARTsender("b");


to

Code C - [expand]
1
UARTsender('b');


How did I missed it, It will show an compilation error... :smile:
 
I changed it but it still not working :(

i use a crystal of 16mhz and the baud rate is 1200 bps
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top