belal elkady
Newbie level 6
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();
}
}