AnsweredAssumed Answered

Help me get string for stm8l152c8 through usart communication

Question asked by nguyen_anh.chuan on Sep 13, 2014
Latest reply on Sep 14, 2014 by nguyen_anh.chuan
I'm trying to get a string from usart to stm8l, but when i got 2byte char, the RXNE is clear, and i can't get anymore char.

My code is:

main
{
    int8_t count = 0;
    getdata  = "";
    while(1)
    {
        getdata[count++] = getchar();
        
        if(getdata[0]==0x0D&&getdata[1]==0x0A)
        {
          getdata[0]=getdata[1]=NULL; count=0;
        }
        if(getdata[count-1]==0x0A)
        {
          getdata[count-1]=NULL;
          getdata[count]=NULL;
       break;
     }
    }

}

GETCHAR_PROTOTYPE
{
  char c = 0;
  
  /* ???????  */ 
  while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET); 
  
  /* ??????? */ 
  c = USART_ReceiveData8(USART1);
  
  USART_ClearFlag(USART1, USART_FLAG_RXNE);
  
  return (c); 
}

Please help if you have any idea!
Thanks so much!

Outcomes