erminesh11
Newbie level 4

im placing my code here that i used to communicate atmega16 with pc on hyperteminal. it is working fine. my concern is regarding using at commands in my code. how could i start...
Code:
#define F_CPU 16000000UL
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
#include<avr/io.h>
#include<util/delay.h>
void usart_init();
void usart_putch(unsigned char send);
unsigned int usart_getch();
int main()
{
unsigned char value;
DDRD=0xff;
DDRA=0xff;
DDRB=0x07;
_delay_ms(50); // delay of 50 mili seconds
usart_init(); // initialization of USART
while(1)
{
value=usart_getch();
usart_putch(value);
}
return 0;
}
void usart_init()
{
UCSRB |= (1 << RXEN) | (1 << TXEN);
// Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
// Use 8-bit character sizes
UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value..
// into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}
void usart_putch(unsigned char send)
{
while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
// for more data to be written to it
UDR = send; // Send the byte
}
unsigned int usart_getch()
{
while ((UCSRA & (1 << RXC)) == 0);
// Do nothing until data have been received and is ready to be read from UDR
return(UDR); // return the byte
}