hey ppl recently i got a new sharp ir , show i decided calibrate it by using uart , but when i got into hyperterminal but the hyperterminal window remained completely blank ..
my code is like this
# include<stdio.h>
# include<avr/io.h>
# include<util/delay.h>
# include<avr/interrupt.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
unsigned int a;
void adcinitialize();
void uartinitialize();
void adcgetvalue();
int main()
{
adcinitialize();
uartinitialize();
while(1)
{
adcgetvalue();
while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
UDR = a; // Send out the byte value in the variable "a"
while((UCSRA &(1<< UDRE))==0) {};
}
return(1);
}
void adcinitialize()
{
ADCSRA|=_BV(7)|_BV(2)|_BV(1);
ADMUX=0x60;
ADCSRA|=(1<<ADSC);
while(!(ADCSRA & (1<<ADIF)));
ADCSRA|=(1<<ADIF);
a=ADCH;
}
void uartinitialize()
{
UCSRB|=(1<<RXEN)|(1<<TXEN);
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
UBRRL=BAUD_PRESCALE;
UBRRH=(BAUD_PRESCALE>>
;
}
void adcgetvalue()
{
ADMUX=0x61;
ADCSRA|=(1<<ADSC);
while(!(ADCSRA & (1<<ADIF)));
ADCSRA|=(1<<ADIF);
a=ADCH;
}
can anyone tell me whats the fault with my code , i need to know abt it as quickly as possible , oh yes my mcu is clocked at 8 mhz internal clock thanks..