Skip to main content
AElta.1
Associate II
October 4, 2022
Solved

Do several UART transmissions at the same time

  • October 4, 2022
  • 1 reply
  • 764 views

I am trying to transmit (65535 bytes) 3 buffers through UART I just want to transmit all of them. the main buffer is separated into 3 DATA buffers when I tried to transmit all of them I will be able transmit only DATA1.

**/* USER CODE BEGIN PD */
#define MAX_FRAME_SIZE 196605
#define FRAME 65535
/* USER CODE END PD */
/* USER CODE BEGIN PV */
static uint8_t aFull_Buffer[MAX_FRAME_SIZE];
static uint8_t DATA1[FRAME];
static uint8_t DATA2[FRAME];
static uint8_t DATA3[FRAME];
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_TIM1_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_TIM2_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */
static void TransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1);
int main(void)
{
HAL_DMA_Start_IT(htim1.hdma[TIM_DMA_ID_CC1], GPIOC_IDR, (uint32_t) &aFull_Buffer, MAX_FRAME_SIZE);
 
 
 // Enable timer to trigger DMA transfer - CC1DE bit
 __HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_CC1);
 
 // Enable timer input capture
 HAL_TIM_IC_Start(&htim1, TIM_CHANNEL_1);
while (1) {}}
 
static void TransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1) {for (i = 0; i < 65534; i++){
 DATA1[j]=aFull_Buffer[i];
 DATA2[j]=aFull_Buffer[i+FRAME];
 DATA3[j]=aFull_Buffer[i+FRAME+FRAME+FRAME];
j++;
 
 }
HAL_UART_Transmit_DMA(&huart3,DATA1,FRAME);
 HAL_Delay (3000);
HAL_UART_Transmit_DMA(&huart3,DATA2,FRAME);
 HAL_Delay (3000); 
HAL_UART_Transmit_DMA(&huart3,DATA3,FRAME);
 HAL_Delay (3000); 
}**

This topic has been closed for replies.
Best answer by Jaroslav JANOS

Hello AElta.1,

first of all, there is an error when you are filling the DATA3 buffer:

DATA3[j]=aFull_Buffer[i+FRAME+FRAME+FRAME];

There should be only 2 "FRAME"s.

Regarding your problem with UART, try blocking mode first (HAL_UART_Transmit()), and also check the return codes, the UART was probably still busy with transmission of your first buffer and could not send the other two.

BR,

Jaroslav

1 reply

Jaroslav JANOS
Jaroslav JANOSBest answer
ST Employee
October 4, 2022

Hello AElta.1,

first of all, there is an error when you are filling the DATA3 buffer:

DATA3[j]=aFull_Buffer[i+FRAME+FRAME+FRAME];

There should be only 2 "FRAME"s.

Regarding your problem with UART, try blocking mode first (HAL_UART_Transmit()), and also check the return codes, the UART was probably still busy with transmission of your first buffer and could not send the other two.

BR,

Jaroslav

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.