Microcontroller › AVR › problem with program of ATmega16 for sms based device control
- This topic has 4 replies, 3 voices, and was last updated 11 years, 4 months ago by Shashank Rao.C.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
May 28, 2013 at 6:35 pm #2451Shashank Rao.CParticipant
hello friends. I have written a coding for sms based device control using ATmega16. when i try to compile this using avr studio 6 it gives an error and many warnings. i tried my self but no use. i don’t know the program logic is correct or not. please help me.
coding is as bellow.
erroe is conflicting type for ‘cmpr_strng’
#define F_CPU 12000000UL // set CPU freq.#define USART_BAUDRATE 9600#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) – 1)#include<avr/io.h>#include<util/delay.h>#define LCD_DATA PORTA // LCD DATA PORT.#define ctrl PORTB // CONTROL PORT FOR LCD.#define en PB2 // ENABLE SINGNAL FOR LCD.#define rw PB1 // READ/WRITE SIGNAL FOR LCD.#define rs PB0 // REGISTER SELECTION SIGNAL FOR LCD.#define MOTOR_CONTROL PORTC // MOTOR CONTROL PORT.void LCD_cmd(unsigned char cmd);void init_LCD(void);void LCD_write(unsigned char data);void usart_init();void usart_putch(unsigned char send);unsigned int usart_getch();void compr_strng();unsigned int final_result,fresult;unsigned char msg[10] = “”;unsigned char on[]=”MTR ON”;unsigned char off[]=”MTR OFF”;int main(void){while(1){uart_init(); // initialize UART port.usart_putch(“ATrn”); // Sent AT into USART._delay_ms(10000);usart_putch(“AT+CMGF=1rn”); //Select message mode in text mode._delay_ms(1000);usart_putch(“AT+CPMS=’SM’rn”); // Select the message memory._delay_ms(1000);usart_putch(“AT+CMGR=1rn”); // Read the message from index 1.usart_getch(msg[10]);compr_strng();final_result=fresult;if(final_result==0){PORTC=0x01;usart_putch(“ATrn”); // Sent AT into USART._delay_ms(10000);usart_putch(“AT+CMGF=1rn”); //Select message mode in text mode._delay_ms(1000);usart_putch(“AT+CPMS=’SM’rn”); // Select the message memory._delay_ms(1000);usart_putch(“AT+CMGS=+918197103408rn”); // SEND the message.usart_putch(“MOTER IS ON.”);init_LCD();LCD_write(“MOTOR IS ON.”);}if(final_result==1){PORTC=0x00;usart_putch(“ATrn”); // Sent AT into USART._delay_ms(10000);usart_putch(“AT+CMGF=1rn”); //Select message mode in text mode._delay_ms(1000);usart_putch(“AT+CPMS=’SM’rn”); // Select the message memory._delay_ms(1000);usart_putch(“AT+CMGS=+918197103408rn”); // SEND the message.usart_putch(“MOTER IS OFF.”);init_LCD();LCD_write(“MOTER IS OFF.”);}}}void init_LCD(void) //Function to initialize LCD.{LCD_cmd(0x38);_delay_ms(1);// initialization of 16X2 LCD in 8bit mode.LCD_cmd(0x01); // clear LCD_delay_ms(1);LCD_cmd(0x0E); // cursor ON_delay_ms(1);LCD_cmd(0x80); // FIRST ROW 0TH POSITION._delay_ms(1);return;}void LCD_cmd(unsigned char cmd) //Function to LCD command.{LCD_DATA=cmd;ctrl =(0<<rs)|(0<<rw)|(1<<en);_delay_ms(1);ctrl =(0<<rs)|(0<<rw)|(0<<en);_delay_ms(50);return;}void LCD_write(unsigned char data) //Function to write a letter in LCD.{LCD_DATA= data;ctrl = (1<<rs)|(0<<rw)|(1<<en);_delay_ms(1);ctrl = (1<<rs)|(0<<rw)|(0<<en);_delay_ms(50);return ;}void LCD_write_string(unsigned char *str) //Function to write a string in LCD AND STORE ADDRESS value of the string in pointer *str{int i=0;while(str!=’