I have got a sim900 module which has a rs232 serial port. when I connect it to my computer it works fine on a terminal but when I connect it to an atmega16 micro controller it only echoes back what ever I send to it and does not answer to commands. besides i use a max232 ic to convert rs232 to ttl.
#include <io.h>
#include <mega16a.h>
#include <alcd.h>
#include <delay.h>
#include <stdio.h>
interrupt [USART_RXC] void usart_rx_isr(void)
{
char status,data;
status=UCSRA;
data=UDR;
if(data!=0xd && data!= 0xa)lcd_putchar(data);
}
void main(void)
{
////////////////////////I/O REGISTERS
DDRB = 1 << DDB0;
///////////////////////USART REGISTERS
UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
UCSRB=(1<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UBRRH=0x00;
UBRRL=0x33;
///////////////////////ENABLE GLOBAL INTERUPTS
#asm("sei")
///////////////////////LCD CONFIGURATION
lcd_init(16);
lcd_gotoxy(0,0);
delay_ms(2000);
printf("ATE0\r\n");
delay_ms(2000);
printf("ATD+989190077175;\r\n");
delay_ms(20000);
while (1)
{
lcd_clear();
lcd_gotoxy(0,0);
// Please write your application code here
printf("AT\r\n");
delay_ms(2000);
}
}