Question
Help me get string for stm8l152c8 through usart communication
Posted on September 13, 2014 at 08:33
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!