<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>i have made this code for receive string and store it into an array then comparing it to perform task but its not working.help me to get eny sollution</title><link>https://community.element14.com/technologies/code_exchange/w/documents/4893/i-have-made-this-code-for-receive-string-and-store-it-into-an-array-then-comparing-it-to-perform-task-but-its-not-working-help-me-to-get-eny-sollution</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>i have made this code for receive string and store it into an array then comparing it to perform task but its not working.help me to get eny sollution</title><link>https://community.element14.com/technologies/code_exchange/w/documents/4893/i-have-made-this-code-for-receive-string-and-store-it-into-an-array-then-comparing-it-to-perform-task-but-its-not-working-help-me-to-get-eny-sollution</link><pubDate>Wed, 06 Oct 2021 22:22:18 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1d780079-4e4e-44e5-90ae-7f63538a8a59</guid><dc:creator>gk.rajatc</dc:creator><comments>https://community.element14.com/technologies/code_exchange/w/documents/4893/i-have-made-this-code-for-receive-string-and-store-it-into-an-array-then-comparing-it-to-perform-task-but-its-not-working-help-me-to-get-eny-sollution#comments</comments><description>Current Revision posted to Documents by gk.rajatc on 10/6/2021 10:22:18 PM&lt;br /&gt;
&lt;p style="margin:0;"&gt;#ifndef F_CPU&lt;/p&gt;&lt;p style="margin:0;"&gt;#define F_CPU 8000000UL // 16Mhz clock speed&lt;/p&gt;&lt;p style="margin:0;"&gt;#endif&lt;/p&gt;&lt;p style="margin:0;"&gt;#include &amp;lt;avr/io.h&amp;gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;#include &amp;lt;util/delay.h&amp;gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;#include &amp;lt;string.h&amp;gt;&lt;/p&gt;&lt;p style="margin:0;"&gt;//#define USART_BAUDRATE 9600&lt;/p&gt;&lt;p style="margin:0;"&gt;#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1)&lt;/p&gt;&lt;p style="margin:0;"&gt;#define LED_ON&amp;nbsp; PORTD |= (1&amp;lt;&amp;lt;PIND6);&lt;/p&gt;&lt;p style="margin:0;"&gt;#define LED_OFF6&amp;nbsp; PORTD &amp;amp;= ~(1&amp;lt;&amp;lt;PIND6);&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;volatile unsigned char string[15],x,i =0;&lt;/p&gt;&lt;p style="margin:0;"&gt;volatile char Reply_CallReady[15]=&amp;quot;apple&amp;quot;;&lt;/p&gt;&lt;p style="margin:0;"&gt;volatile char C;&lt;/p&gt;&lt;p style="margin:0;"&gt;volatile char data[10];&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;void UART_init(long USART_BAUDRATE)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;UCSRB |=(1&amp;lt;&amp;lt;RXEN)|(1&amp;lt;&amp;lt;TXEN)|(1&amp;lt;&amp;lt;RXCIE);//TURN ON TRANSMISSION AND RECEPTION.&lt;/p&gt;&lt;p style="margin:0;"&gt;UCSRC |=(1&amp;lt;&amp;lt;URSEL)|(1&amp;lt;&amp;lt;UCSZ0)|(1&amp;lt;&amp;lt;UCSZ1);//USE 8 BIT CHARACTER.&lt;/p&gt;&lt;p style="margin:0;"&gt;UBRRL |=(BAUD_PRESCALE);//LOAD LOWER 8 BITS OF THE BAUD RATE VALUE.&lt;/p&gt;&lt;p style="margin:0;"&gt;UBRRH |=(BAUD_PRESCALE&amp;gt;&amp;gt;8);//LOAD UPPER 8 BIT.&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;unsigned char UART_Rxchar()&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;while((UCSRA &amp;amp; (1&amp;lt;&amp;lt;RXC))==0);//wait till data is received.&lt;/p&gt;&lt;p style="margin:0;"&gt;return(UDR);//RETURN THE BYTE.&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;void UART_Txchar(char ch)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;while (!(UCSRA &amp;amp; (1&amp;lt;&amp;lt;UDRE)));//wait for empty transmit buffer.&lt;/p&gt;&lt;p style="margin:0;"&gt;UDR=ch;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;void UART_sendstring(char *str)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;unsigned char j=0;&lt;/p&gt;&lt;p style="margin:0;"&gt;while(str[j]!=0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // send string till null.&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;UART_Txchar(str[j]);&lt;/p&gt;&lt;p style="margin:0;"&gt;j++;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;void lcd_cmd(char cm)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;char a=cm;&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTA=a;&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTB=(0&amp;lt;&amp;lt;PD0)|(0&amp;lt;&amp;lt;PD1)|(1&amp;lt;&amp;lt;PD2);&lt;/p&gt;&lt;p style="margin:0;"&gt;_delay_ms(50);&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTB=(0&amp;lt;&amp;lt;PD0)|(0&amp;lt;&amp;lt;PD1)|(0&amp;lt;&amp;lt;PD2);&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;void lcd_data(char dat)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;char b=dat;&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTA=b;&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTB=(1&amp;lt;&amp;lt;PD0)|(0&amp;lt;&amp;lt;PD1)|(1&amp;lt;&amp;lt;PD2);&lt;/p&gt;&lt;p style="margin:0;"&gt;_delay_ms(50);&lt;/p&gt;&lt;p style="margin:0;"&gt;PORTB=(1&amp;lt;&amp;lt;PD0)|(0&amp;lt;&amp;lt;PD1)|(0&amp;lt;&amp;lt;PD2);&lt;/p&gt;&lt;p style="margin:0;"&gt;_delay_ms(50);&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;unsigned char *UART_RX_STR(x)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;while (x != &amp;#39;\0&amp;#39;)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;string[i++] = x;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;return string;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;ISR(USART_RXC_vect)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;C=UDR;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;int main()&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;DDRB=0xFF;&lt;/p&gt;&lt;p style="margin:0;"&gt;DDRA=0xFF;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;UART_init(9600);&lt;/p&gt;&lt;p style="margin:0;"&gt;while(1)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;C=UART_Rxchar();&lt;/p&gt;&lt;p style="margin:0;"&gt;x=C;&lt;/p&gt;&lt;p style="margin:0;"&gt;if (strcmp(string,Reply_CallReady) ==0)&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;LED_ON;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;else&lt;/p&gt;&lt;p style="margin:0;"&gt;{&lt;/p&gt;&lt;p style="margin:0;"&gt;LED_OFF6;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;p style="margin:0;"&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: Code Exchange&lt;/div&gt;
</description></item></channel></rss>