Receive a string 9 chars long through UART1
I would like to receive a string through the UART1,
its format is from 000000000 to 999999999,
However when I send the string only the first object is read and it is repeated nine times and the other values are lost.
I am using this function to read the data from UART
void Serial_read_char(uint8_t * buf, uint8_t numberOfBytes)
{
buf[pos] = UART1_ReceiveData8();
UART1_ClearITPendingBit(UART1_IT_RXNE);
UART1_ClearFlag(UART1_FLAG_RXNE);
pos++;
if(pos > numberOfBytes)
{
pos = 0;
}
}And this is how I am storing the data in the main function
if (UART1_GetFlagStatus(UART1_FLAG_RXNE) == TRUE)
{
Serial_read_char(buf, 9);
delay_ms(1);
get_lux = (*(buf+0) - 0x30)*100+
(*(buf+1) - 0x30)*10 +
(*(buf+2) - 0x30);
get_warm =(*(buf+3) - 0x30)*100+
(*(buf+4) - 0x30)*10 +
(*(buf+5) - 0x30);
get_cool =(*(buf+6) - 0x30)*100+
(*(buf+7) - 0x30)*10 +
(*(buf+8) - 0x30);
}How could I read correctly the value from the String?
I am using the STM8S208C6 and the Cosmic compiler free
