Ammy Rao
Junior Member level 1
- Joined
- May 4, 2013
- Messages
- 17
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,403
#include<avr/io.h>
#include<util/delay.h>
#define LCD_DATA PORTA // lcd data port A
#define ctrl PORTB
#define en PB2
#define rw PB1
#define rs PB0
#define F_CPU 8000000UL
#define USART_BAUDRATE 9600 // Baud Rate value
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
unsigned char string [40];
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void LCD_string (unsigned char *str);
void init_LCD (void)
{
LCD_cmd (0x38); //
_delay_ms(10);
LCD_cmd (0x01); //clear LED
_delay_ms(10);
LCD_cmd (0x0E); //cursor ON, blinking
_delay_ms(10);
LCD_cmd (0x80);
_delay_ms(50);
return;
}
void LCD_cmd (unsigned char cmd)
{
LCD_DATA = cmd;
ctrl=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);
ctrl=(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
void LCD_write (unsigned char data)
{
LCD_DATA = data;
ctrl=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);
ctrl=(1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
void LCD_string (unsigned char *str)
{
int i=0;
while (str[i]!='\0')
{
LCD_write (str[i++]);
}
}
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
}
unsigned int usart_ReadChar()
{
while ((UCSRA & (1 << RXC)) == 0);
// Do nothing until data has been received and is ready to be read from UDR
return(UDR); // return the byte
}
void usart_WriteChar(unsigned char data)
{
//Wait untill the transmitter is ready
while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
// for more data to be written to it
UDR = data; // Send the byte
}
int main()
{
unsigned char data;
DDRA=0xff; //LCD_DATA port as output port
DDRB=0x07; //signal as out put
init_LCD(); //initialization of LCD
_delay_ms(1);
LCD_string ("HOME");
_delay_ms(100);
usart_init();
// sei(); // Enable global interrupt
usart_WriteChar('A');
usart_WriteChar('T');
usart_WriteChar('\n');
//Check whether response is OK or not
_delay_ms(300);
LCD_cmd(0x01);
data=usart_ReadChar();
LCD_write(data);
}
#include<avr/io.h>
#include<util/delay.h>
#define LCD_DATA PORTA // lcd data port A
#define ctrl PORTB
#define en PB2
#define rw PB1
#define rs PB0
#define F_CPU 8000000UL
#define USART_BAUDRATE 9600 // Baud Rate value
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
unsigned char string [40];
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void LCD_string (unsigned char *str);
void init_LCD (void)
{
LCD_cmd (0x38); //
_delay_ms(10);
LCD_cmd (0x01); //clear LED
_delay_ms(10);
LCD_cmd (0x0E); //cursor ON, blinking
_delay_ms(10);
LCD_cmd (0x80);
_delay_ms(50);
return;
}
void LCD_cmd (unsigned char cmd)
{
LCD_DATA = cmd;
ctrl=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);
ctrl=(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
void LCD_write (unsigned char data)
{
LCD_DATA = data;
ctrl=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(10);
ctrl=(1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
void LCD_string (unsigned char *str)
{
int i=0;
while (str[i]!='\0')
{
LCD_write (str[i++]);
}
}
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
}
unsigned int usart_ReadChar()
{
while ((UCSRA & (1 << RXC)) == 0);
// Do nothing until data has been received and is ready to be read from UDR
return(UDR); // return the byte
}
void usart_WriteChar(unsigned char data)
{
//Wait untill the transmitter is ready
while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
// for more data to be written to it
UDR = data; // Send the byte
}
int main()
{
unsigned char data;
DDRA=0xff; //LCD_DATA port as output port
DDRB=0x07; //signal as out put
init_LCD(); //initialization of LCD
_delay_ms(1);
LCD_string ("HOME");
_delay_ms(100);
usart_init();
// sei(); // Enable global interrupt
usart_WriteChar('A');
usart_WriteChar('T');
usart_WriteChar('\n');
//Check whether response is OK or not
_delay_ms(300);
LCD_cmd(0x01);
data=usart_ReadChar();
LCD_write(data);
}
@mahendra
SIM300 board is already having MAX232...even then i hv to connect MAX232 between uc and db9 connector ?
yes. your sim300 is not giving TTL output. so to convert it to TTL you have to connect another max 232 with DB9.with cross connection of wire.1 end (2-RX,3-TX,5-GND) another end(2-TX,3-RX,5-GND) otherwise check the GSm modem in Max 232IC
if they have used 11,12,13,14 pins.then take output from 11 & 12 .connect directly to microcntroller without another max232
In which part you were wrong...
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?