Forum Replies Created
-
AuthorPosts
-
hardeepParticipant
Can anyone help me out with the programming logic ???
hardeepParticipantMy GSM modem and AVR usart are working fine individually….but when i connect modem to controller,i
#include<avr/io.h>#include<util/delay.h>#define F_CPU 11059200UL#define USART_BAUDRATE 9600 // Baud Rate value#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) – 1)#define LCD_DATA PORTB //LCD data port#define ctrl PORTD#define en PD2 // enable signal#define rw PD3 // read/write signal#define rs PD4 // register select signalvoid usart_putstr(char * s);void LCD_cmd(unsigned char cmd);void init_LCD(void);void LCD_write(unsigned char data);void usart_init();static void usart_putch(unsigned char send);unsigned int usart_getch();void gotoxy(unsigned char row,unsigned char column);static void LCD_String(char *s);int main(){unsigned char value,i;DDRB=0xff; // LCD_DATA port as output portPORTB=0x00;DDRD|=0xFC;init_LCD(); //initialization of LCD_delay_ms(50); // delay of 50 milli secondsusart_init(); // initialization of USARTgotoxy(1,1);//char a[] = “AT”;char b[] = “AT+CMGS=”;char no[]=”+919595955635″;char body[] = “Successful”;{//usart_putstr(a);//_delay_ms(5);// usart_putstr(“rn”);// _delay_ms(100);usart_putstr(b);_delay_ms(100);usart_putch(‘”‘);// _delay_ms(100);usart_putstr(no);// _delay_ms(100);usart_putch(‘”‘);_delay_ms(100);usart_putch(‘r’);usart_putch(‘n’);_delay_ms(100);usart_putstr(body);_delay_ms(100);usart_putch(0x1A);// for (i=0;i<16;i++)// {// value=usart_getch(); // Call a function to get data from serial port// _delay_ms(100);// LCD_write(value); // write data to LCD// }// gotoxy(2,1);}return 0;}void init_LCD(void){LCD_cmd(0x38); // initialization of 16X2 LCD in 8bit mode_delay_ms(1);LCD_cmd(0x01); // clear LCD_delay_ms(1);LCD_cmd(0x0E); // cursor ON_delay_ms(1);LCD_cmd(0x80); // —8 go to first line and –0 is for 0th position_delay_ms(1);return;}void LCD_cmd(unsigned char cmd){LCD_DATA=cmd;ctrl &=~ (1<<rs);ctrl&=~(1<<rw);ctrl|=(1<<en); // RS and RW as LOW and EN as HIGH_delay_ms(1);ctrl &=~ (1<<rs);ctrl&=~(1<<rw);ctrl&=~(1<<en); // RS, RW , LOW and EN as LOW_delay_ms(1);return;}void LCD_write(unsigned char data){LCD_DATA= data;ctrl |= (1<<rs);ctrl&=~(1<<rw);ctrl|=(1<<en); // RW as LOW and RS, EN as HIGH_delay_ms(1);ctrl |= (1<<rs);ctrl&=~(1<<rw);ctrl&=~(1<<en); // EN and RW as LOW and RS HIGH_delay_ms(1); // delay to get things executed return ;}void usart_init(){UBRRL = 0x47;// UBRRL = (unsigned char)BAUD_PRESCALE;// Load lower 8-bits of the baud rate value into the low byte of the UBRR register// UBRRH = (unsigned char)(BAUD_PRESCALE>>; // Load upper 8-bits of the baud rate value.._delay_ms(1);UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitryUCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);// Use 8-bit character sizes}unsigned int usart_getch(){while (!(UCSRA & (1 << RXC)) );// Do nothing until data has been received and is ready to be read from UDR_delay_ms(1);return(UDR); // return the byte}static void usart_putch(unsigned char send){while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..// for more data to be written to itUDR = send; // Send the byte}void gotoxy(unsigned char row,unsigned char column){switch (row){case 1: LCD_cmd (0x80 + column – 1); break;case 2: LCD_cmd (0xc0 + column – 1); break;default: break;}}static void LCD_String(char *s){register char c;while((c = *s++)){_delay_ms(10);LCD_write(c);}return;}void usart_putstr(char * s){while(*s){usart_putch(*s++);}}am not receiving messages…
hardeepParticipantI am not getting how to interface it with ATMEGA16…plz help me with the coding part…!!!
How to send the string to the modem using usart and all…
Individually my usart is running fine and GSM modem also running fine…but i m not able to interface modem to atmega16…!!!
hardeepParticipantThanks a lot…!!! It helped me…
hardeepParticipantI have done the same program….and the program is not for loop back…its to send the code to the microcontroller…!!!
The controller is just receiving the data…
hardeepParticipantStill not working…
hardeepParticipantNothng is getting printed buddy …!!!
hardeepParticipantThanks a lot buddy…
bt when i use thisfor(i=0;i<2;i++){ar=(value_t)%10;(value_t)=(value_t)/10;}LCD_write(0x30+ar[2]);LCD_write(0x30+ar[1]);LCD_write(‘.’);LCD_write(0x30+ar[0]);LCD_write(‘d’);LCD_write(‘C’);_delay_ms(100);
the first digit is not getting printed…plz help…!!!
hardeepParticipantUse ponyprog to burn ur program…
Before burning,go to command=>security and configuration bits
There disablt jtag and click on write…Its done…!!!hardeepParticipantThanks but i need help in codong too…
-
AuthorPosts