AnsweredAssumed Answered

array to string in usart peripheral

Question asked by gusonela.septian on Jun 6, 2014
Latest reply on Jun 7, 2014 by Andrew Neil
i know about usart, for transmited by transmittter and received data by receiver i can do it.. i communication usart use looping and use array too... how can i make this array to become string  so i can use function like this

if (x="septian")
{
led on
}

this my concept transmit and receive data 

void cetak(char huruf[20])
{
     unsigned char jumlah;
     unsigned char i;
     jumlah = strlen(huruf);
     for(i=0;i<jumlah;i++)USART1_PutChar(huruf[i]);
}

void USART1_PutChar(char c)
{
     uint8_t ch;
     ch=c;
     USART_SendData(USART1,ch);
     while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
}
 

and for received data and feedback it use this

void USART1_IRQHandler()
{
     if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET)
     {
          receiver_to_feedback();
          USART_ClearITPendingBit(USART1,USART_IT_RXNE);
     }
}

void receiver_to_feedback()
{
     uint8_t i=0;
     char resp[20]="";
     int a;
     do
                   {
                        while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
                        resp[i] = USART_ReceiveData(USART1);
                        i++;


                   }while(resp[i-1]!=32);
                    for( a=0; a<i-1; a++)
                        {
                        USART1_PutChar(resp[a]);
                        }
                   USART1_PutChar(' ');
                   i=0;
}


maybe someone can help me,, please :D

Outcomes