cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 and dynamic graph

nsabo.1
Associate II

Hi, I want to receive 20 bytes.

I want to receive them every 2 milliseconds and simultaneously.

To show data, I am working with TOUCHGFX. I use dynamic graphs to show them.

The problem is, I want to show 12 bits on each graph.

I debugged my code , it seams I don't loose data.

but my graph is not fed correctly.

I have 2 signs in my data packets, first is 240 and last is 180.

here is the code:

  void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){

   if(Sign[0]==240){

   HAL_UART_Receive(&huart1,(uint8_t*)RxBuf,19,100);

  

    FlagFinsh=1;

  

   HAL_UART_Receive_IT(&huart1,(uint8_t*)Sign,1);

   }else {

   HAL_UART_Receive_IT(&huart1,(uint8_t*)Sign,1);

  HAL_GPIO_TogglePin(RED_GPIO_Port, RED_Pin);

   }

  

    

  }

and in my touchgfx screen in handletickevent function , I just extern and add data to graph:

  void Screen2View::handleTickEvent()

{

  tickCounter++; 

if(FlagFinsh==1){

FlagFinsh=0;

if(++i > 120) i=0;

     Data= (((RxBuf[3] >> 4)*256)+RxBuf[1])- 1700;

  

dynamicGraph1.addDataPoint(Data);

  }

Thanks.

5 REPLIES 5
MM..1
Chief II

If your code do nothink more, then maybe can work, but place into interrupt callback pool blocking func, that receive 19 bytes is very ugly.

Next mistake is use RxBuf in handleTick event. For Example RxBuf[3] is old received and [1] new overwriten, because flagfinish dont stop RX and cant...

How type is RxBuf ???

Touch GFX #5. Display UART data on the Screen using MVP (Model View Presenter) - YouTube

in video same mistake if next RX start soon as model tick executed.

Hi, I just configured USART1 is receiving all my data correctly.

I have a problem while the dynamic graph wants to show my data.

RxBuf is uint8_t form.

exactly as you said, it seems old one is still displaying while new data is received and my buffer has not been updated, so graph is displaying false data.

Is touch GFX able to display my project?

I am working on a real data and it is important for me to display them every packets in 2 milliseconds I am so confused...

Hi, yes I wanted to delete it but it did not let me... thanks

Primary you need understand what you do. Handletick event is based on screen refresh clock and repeat every XXms that is more as 2ms.

Seconary your USART cant work with one RxBuf for this idea or you need next buff in RXcallback where you store valid datapoints for graph.

Your callback maybe receive all data but block MCU against do other things.

Rewrite your code ... callback IT receive ... in calbacka store into point array FIFO.

In GUI get from FIFO and show/add available points in one handletick.

And yes TouchGFX is able , but you ?