cancel
Showing results for 
Search instead for 
Did you mean: 

How to show data received by UART to graph?

nsabo.1
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

RxBuf[0] would contain the data, you'd need to wait for the callback for the data to be present

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5
Karl Yamashita
Lead II

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.

I Can't Believe It's Not Butter. If you find my answers useful, click the accept button so that way others can see the solution.

RxBuf[0] would contain the data, you'd need to wait for the callback for the data to be present

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

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 
}
 

I Can't Believe It's Not Butter. If you find my answers useful, click the accept button so that way others can see the solution.

I will direct you to my new post.