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 :
that's very simple app:
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();
}
}