Freertos in data acquisition is not consistent sampling rate .

Hello

    i am a newbie in Freertos. i have a practice project about two threads. one thread for data acquisition from AD7606 , another thread  for data transmission by uart  in LabVIEW . Unfortunately, when i display data in LabVIEW which get from thread 2  , i found it will lose data or sampling rate is not consistent . How can i slove this problem?  

Up to now , i don't know whether the solution is timer interrupt in freertos or not .

Please give me the hint or some tutorial i could reference.  Please advise as necessary. Thank you very much.

    

void StartDefaultTask(void const * argument)
{
  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
	 xSemaphoreTake(DeliverHandle,portMAX_DELAY); 	
	 // START read AD7607	
	 Read_AI();  	
	 float value = (float)aio_data.c2_values_in[0];
	 // END read AD7607
	 
	 // Send data in MyQueue
	  xQueueSendToBack(MyQueue, (void*)&value, (TickType_t)1);	
	  xSemaphoreGive(DeliverHandle);
	  osDelay(20);	 
	}
}	


void StartTask02(void const * argument)
{
  /* USER CODE BEGIN StartTask02 */
  /* Infinite loop */
  int messagesWaiting,j;
	float value_f;
	uint32_t value_u32;
  for(;;)
  {
	 //START test queue number 	
	 messagesWaiting = uxQueueMessagesWaiting(MyQueue);
	 xSemaphoreTake(DeliverHandle, portMAX_DELAY);	
	 if ( messagesWaiting >= 8 ) {
		  for(j = 0; j < messagesWaiting; j++){
				 xQueueReceive(MyQueue, &value_f, (TickType_t)1);
				 value_u32 = Convert_float_To_U32(value_f);
				 Covert_U32_To_4U8(value_u32, Tx_data+4*j);
			}
			HAL_UART_Transmit(&huart2, Tx_data, 32, 1000);
    }
		osDelay(20);
		xSemaphoreGive(DeliverHandle);
		}
  /* USER CODE END StartTask02 */
}