dadda007
Newbie level 5
atmega max232
I wrote a code to send AT commands from ATmega32 to my Ericson 230 cell , but sadly it is not giving any output ...... I used a RS232(DB9 standard ) cable to interface the cell and the Atmega32, besides i also used MAX232 IC for Voltage conversion . My code is :
The pin connections i used for the RS232 are :
Pin 2 to 14 of MAX232
Pin 3 to 8 of MAX232
Pin 5 Gnd
Pin 4 to Pin 2 of MAX232
Pin 7 to Pin 7 of MAX232
Plz help :!:
I wrote a code to send AT commands from ATmega32 to my Ericson 230 cell , but sadly it is not giving any output ...... I used a RS232(DB9 standard ) cable to interface the cell and the Atmega32, besides i also used MAX232 IC for Voltage conversion . My code is :
Code:
#include<avr/io.h>
#include<util/delay.h>
#define A 0x41
#define C 0x43
#define T 0x54
#define M 0x4d
#define G 0x44
#define D 0x47
#define E 0x48
#define P 0x50
#define S 0x53
void init_txr(void);
void trans_data(char);
int main(void)
{
DDRB=0xff;
DDRA=0xff;
init_txr();
int x[10]={'A','T',0x3d,'C','M','G','D',0x2b,0x01,0x0d},i;
int y[13]={'A','T',0x3d,'C','P','M','S',0x2b,0x22,'M','E',0x22,0x0d};
int z[10]={'A','T',0X3D,'C','M','G','F',0X2B,0X00,0X0D};
while(1)
{
for(i=0;i<13;i++)
trans_data(y[i]);
_delay_ms(50);
for(i=0;i<10;i++)
trans_data(z[i]);
_delay_ms(50);
for(i=0;i<10;i++)
trans_data(x[i]);
_delay_ms(50);
}
return 0;
}
void init_txr(void)
{
//UBRRH=0x00;
UBRRL=0x19;
//UCSRC=0x86;
UCSRB=0x08;
//UCSRA=0x00;
}
void trans_data(char a)
{
while(!(UCSRA & (1<<UDRE)))
;
UDR=a;
PORTA=0x0f;
}
The pin connections i used for the RS232 are :
Pin 2 to 14 of MAX232
Pin 3 to 8 of MAX232
Pin 5 Gnd
Pin 4 to Pin 2 of MAX232
Pin 7 to Pin 7 of MAX232
Plz help :!: