2022-12-25 02:21 AM
Hi, I want to receive data by UART and display them by graph.
Here is my code:
```
HAL_UART_Receive_IT(&huart1,(uint8_t*)RxBuf,1);
RxBuf[1]=r1[i];
```
and show by graph:
```
if(i<256){
dynamicGraph1.addDataPoint(r1[i++] );
}else
i=0;
```
the problem is a straight line shown and not correct.
Solved! Go to Solution.
2022-12-25 10:00 AM
RxBuf[0] would contain the data, you'd need to wait for the callback for the data to be present
2022-12-25 08:16 AM
You need to fix your code. RxBuf holds your value already when you get an interrupt. So you're graphing the value of r1, not RxBuf value.
2022-12-25 10:00 AM
RxBuf[0] would contain the data, you'd need to wait for the callback for the data to be present
2022-12-26 01:11 AM
Thanks for your help.
Receiving data by UART and display it by TOUCHGFX cause some lost data in my screen, graph is not displayed correctly.
There are 2 boards one which is been receiving the signals by sensors and the second one is LCD board which has been configured by TOUCHGFX.
I want to receive data by UART from the first board and show them in LCD.
But some graph is not shown correctly.
Here is the code:
```
HAL_UART_Receive_IT(&huart1,(uint8_t*)RxBuf,20);
HAL_UART_RxCpltCallback(&huart1);
HAL_Delay(1);
```
I put ```HAL_Delay(1); ``` in order to receive data correctly but it does not make sense.
And the data shown by graph:
```
if(i<123){
dynamicGraph1.addDataPoint(RxBuf[1]+25);
}else
i=0;
```
How can I solve it?
Thanks again.
2022-12-26 03:09 AM
You're posting incomplete code that makes no sense. Copy and paste exactly how you've written your code. And use the code snippet formatting by clicking on the </> icon so you're showing something like this below
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
// your complete code
}
2022-12-26 03:17 AM
I will direct you to my new post.