sir actually this is my serial program to send a letter 'a' on hyper terminal but when i try to load the program to controller ATMEGA 32 and try to display on hyperterminal i am unable to get the data. please help me out as soon as possible
#include <avr/io.h>
int main(void)
{
UCSRC |= (1<<UMSEL); // select asynchronous mode
UCSRC |= (1<<USBS);
UBRRH = 51>>8; // higher 8 bits of 51
UBRRL = 51; // lower 8 bits of 51
UCSRB |= (1<<RXEN)|(1<<TXEN); // enable transmitter and receiver both
UCSRC |= (1<<UCSZ0)|(1<<UCSZ1); // number of data bits is 8
Where is your interrupt routine for serial communication and you have to include interrupt.h file. I think you are using Atmel Studio. Use the code in the pdf I posted.
#include < avr / io .h >#include < avr / interrupt .h >#define USART_BAUDRATE 9600#define BAUD_PRESCALE ((( F_CPU / ( USART_BAUDRATE * 16 UL ))) - 1)int main (void){
UCSRB |=(1<< RXEN )|(1<< TXEN );// Turn on the transmission and reception circuitry
UCSRC |=(1<< URSEL )|(1<< UCSZ0 )|(1<< UCSZ1 );// Use 8-bit character sizes
UBRRH =( BAUD_PRESCALE >>8);// Load upper 8-bits of the baud rate value into the high byte
of the UBRR register
UBRRL = BAUD_PRESCALE ;// Load lower 8 -bits of the baud rate value into the low byte of the
UBRR register
UCSRB |=(1<< RXCIE );// Enable the USART Recieve Complete interrupt (USART_RXC)
sei ();// Enable the Global Interrupt Enable flag so that interrupts can be processedfor(;;)// Loop forever{// Do nothing - echoing is handled by the ISR instead of in the main loop}}
ISR ( USART_RXC_vect ){char ReceivedByte ;
ReceivedByte = UDR ;// Fetch the received byte value into the variable "ByteReceived"
UDR = ReceivedByte ;// Echo back the received byte back to the computer}