2020-10-13 12:05 AM
I want to use circular DMA to receive data of unknown length on 4 uarts of STM32F730R8, but I receive data just on first two of them. Transmission works and I use HAL library. Code is generated by MX configuration tool and all uarts are configured identically.
HAL_UART_Receive_DMA(&huart1,readBuffer,sizeof(readBuffer));
HAL_UART_Receive_DMA(&huart2,debgBuffer,sizeof(debgBuffer));
HAL_UART_Receive_DMA(&huart3,Buffer1,sizeof(Buffer1));
HAL_UART_Receive_DMA(&huart4,Buffer2,sizeof(Buffer2));
HAL_UART_Receive_DMA(&huart6,Buffer3,sizeof(Buffer3));
HAL_UART_Transmit(&huart1, (uint8_t *)&"\nHello mr. Freeman", 18, 0xFFFF);
HAL_UART_Transmit(&huart2, (uint8_t *)&"\nHello mr. Freeman", 18, 0xFFFF);
HAL_UART_Transmit(&huart3, (uint8_t *)&"\nHello mr. Freeman", 18, 0xFFFF);
HAL_UART_Transmit(&huart4, (uint8_t *)&"\nHello mr. Freeman", 18, 0xFFFF);
HAL_UART_Transmit(&huart6, (uint8_t *)&"\nHello mr. Freeman", 18, 0xFFFF);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
for(int i = 0; i<sizeof(readBuffer); i++){
RX[i] = readBuffer[i];
if(RX[i] == 0xA5){
HAL_UART_Transmit(&huart1, (uint8_t *)&"\nWelcome to city 17", 19, 0xFFFF);
}
readBuffer[i] = 0;
}
for(int i = 0; i<sizeof(debgBuffer); i++){
dbgRX[i] = debgBuffer[i];
if(dbgRX[i] == 0xA5){
HAL_UART_Transmit(&huart2, (uint8_t *)&"\nWelcome to city 18", 19, 0xFFFF);
}
debgBuffer[i] = 0;
}
for(int i = 0; i<sizeof(Buffer1); i++){
RX1[i] = Buffer1[i];
if(RX1[i] == 0xA5){
HAL_UART_Transmit(&huart3, (uint8_t *)&"\nWelcome to city 19", 19, 0xFFFF);
}
Buffer1[i] = 0;
}
for(int i = 0; i<sizeof(Buffer2); i++){
RX2[i] = Buffer2[i];
if(RX2[i] == 0xA5){
HAL_UART_Transmit(&huart4, (uint8_t *)&"\nWelcome to city 20", 19, 0xFFFF);
}
Buffer2[i] = 0;
}
for(int i = 0; i<sizeof(Buffer3); i++){
RX3[i] = Buffer3[i];
if(RX3[i] == 0xA5){
HAL_UART_Transmit(&huart6, (uint8_t *)&"\nWelcome to city 21", 19, 0xFFFF);
}
Buffer3[i] = 0;
}
}
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA2_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);
/* DMA1_Stream2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn);
/* DMA1_Stream5_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn);
/* DMA2_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
/* DMA2_Stream2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn);
}
2020-10-13 02:19 AM
Polled Rx works?
Read out and check/post content of relevant USART and DMA registers.
JW