arunima.srivastava
Newbie level 1
atmega16 uart
Hi all
I am implementing UART in microcontroller ATmega16.The code is as follows
#define FOSC 6000000
#define BAUD 9600
#define MY_UBRR
#include<avr/io.h>
#include<stdio.h>
void serinit(){
// UBRRH=0x00;
UBRRL=0x26;
UCSRA=0x00;
UCSRB=0x08;
UCSRC=0x86;
// UBRRH=0x00;
return;
}
void sersend(unsigned char c){
while((UCSRA & 0x20)==0);
UDR=c;
return;
}
int main(){
unsigned char i=0;
PORTD=0xff;
DDRD=0xff;
serinit();
while(1){
sersend(50);
i++;
}
return 0;
}
but it is not working.can any body plz help me, suggesting any changes in this code or providing me some other code.
Plz help me asap.
Thnx
Hi all
I am implementing UART in microcontroller ATmega16.The code is as follows
#define FOSC 6000000
#define BAUD 9600
#define MY_UBRR
#include<avr/io.h>
#include<stdio.h>
void serinit(){
// UBRRH=0x00;
UBRRL=0x26;
UCSRA=0x00;
UCSRB=0x08;
UCSRC=0x86;
// UBRRH=0x00;
return;
}
void sersend(unsigned char c){
while((UCSRA & 0x20)==0);
UDR=c;
return;
}
int main(){
unsigned char i=0;
PORTD=0xff;
DDRD=0xff;
serinit();
while(1){
sersend(50);
i++;
}
return 0;
}
but it is not working.can any body plz help me, suggesting any changes in this code or providing me some other code.
Plz help me asap.
Thnx