2018-06-27 12:30 AM
Hi everyone, im trying to send datas to 8 uarts+usarts on stm32f7 mcu. I'm getting datas from ethernet wtih netconn connection. I'm using FreeRTOS and lwIP stack. I have a task that calls netconn_recv(conn, &buf); in infinite loop. When netcon_recv function returns OK i parse datas. Than i send datas to proper ports by interrupt method. But when more than 1 uart data appear at ethernet, my FPS of uart output starts to decrease. I need an advice to increase the speed of data send system.
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart == &huart6)
{
usart6_tx_ready_u8 = TRUE;
}
if(huart == &huart1)
{
usart1_tx_ready_u8 = TRUE;
}
if(huart == &huart2)
{
usart2_tx_ready_u8 = TRUE;
}
if(huart == &huart3)
{
usart3_tx_ready_u8 = TRUE;
}
if(huart == &huart8)
{
usart8_tx_ready_u8 = TRUE;
}
if(huart == &huart7)
{
usart7_tx_ready_u8 = TRUE;
}
if(huart == &huart5)
{
usart5_tx_ready_u8 = TRUE;
}
if(huart == &huart4)
{
usart4_tx_ready_u8 = TRUE;
}
}
/* SEND 4 UART */
void data_send(uint8_t port_no, uint8_t* data_buffer, test_t* TEST, uint16_t size)
{
switch (port_no)
{
case (uint8_t)PORT1:
{
usart5_tx_ready_u8 = FALSE;
MX_UART5_Init2();//change baudrate to SET1
HAL_UART_Transmit_IT(&huart5,TEST->start_buffer,1);
while(usart5_tx_ready_u8 == FALSE);//wait callback
usart5_tx_ready_u8 = FALSE;
MX_UART5_Init();//change baudrate to SET2 again
HAL_UART_Transmit_IT(&huart5, data_buffer,size+1);
while(usart5_tx_ready_u8 == FALSE);
break;
}
case (uint8_t)PORT2:
{
usart6_tx_ready_u8 = FALSE;
MX_USART6_UART_Init2();//change baudrate to SET1
HAL_UART_Transmit_IT(&huart6,TEST->start_buffer,1);
while(usart6_tx_ready_u8 == FALSE);//wait callback
usart6_tx_ready_u8 = FALSE;
MX_USART6_UART_Init();//change baudrate to SET2 again
HAL_UART_Transmit_IT(&huart6, data_buffer,size+1);
while(usart6_tx_ready_u8 == FALSE);
break;
}
case (uint8_t)PORT3:
{
usart7_tx_ready_u8 = FALSE;
MX_UART7_Init2();//change baudrate to SET1
HAL_UART_Transmit_IT(&huart7,TEST->start_buffer,1);
while(usart7_tx_ready_u8 == FALSE);//wait callback
usart7_tx_ready_u8 = FALSE;
MX_UART7_Init();//change baudrate to SET2 again
HAL_UART_Transmit_IT(&huart7, data_buffer,size+1);
while(usart7_tx_ready_u8 == FALSE);
break;
}
case (uint8_t)PORT4:
{
usart8_tx_ready_u8 = FALSE;
MX_UART8_Init2();//change baudrate to SET1
HAL_UART_Transmit_IT(&huart8,TEST->start_buffer,1);
while(usart8_tx_ready_u8 == FALSE);//wait callback
usart8_tx_ready_u8 = FALSE;
MX_UART8_Init();//change baudrate to SET2 again
HAL_UART_Transmit_IT(&huart8, data_buffer,size+1);
while(usart8_tx_ready_u8 == FALSE);
break;
}
default:
{
break;
}
}
}
/* SEND OTHER 4 UART */
void data_send2(uint8_t port_no, uint8_t* data_buffer, test_t* TEST, uint16_t size)
{
...
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
#usart #stm32f-uart #uart-interrupt #ethernet-stm32f7
2018-06-27 03:49 PM
1. See some examples here:
https://github.com/dannyf00/My-MCU-Libraries---2nd-try/tree/master/STM32F0
you can find similar implementations on other platforms. The basic gist is the same.2 and 3: you will come to appreciate it when you get some chance to learn about interrupts and how they work.
Hope it helps.
2018-06-27 04:06 PM
Ok, so you need to remove the waiting/blocking from your code. Queue the interactions you want to occur, in the order you want them to occur and periodically pump or cultivate the specific channel to see if it is ready to move on to the stage.
Where you have 8 possible channels, have 8 queue that can manage any disparity in rates, and chain the transfers in the callback, or via flags you trigger in the callbacks.
2018-06-28 08:56 AM
ismail fatih iltar wrote:
2)i need ~100us low pulse at uart. so i send zero at SET1 baudrate than i change it to SET2 normal comm. baudrate.
I'd really like to understand this better, please. Can you explain this mechanism in more detail?
2018-06-28 09:02 AM
purpose of low pulse is break condition before data. i must handle the tx line app. 100us at low so if i right, i have 2 ways. first one is setting pin tx to gpio and set it to low after that init like a uart again. second one ise changing baudrate dynamically. So i change baudrate to SET1 and send 0x00 to uart to simulate low pulse after that i change baudrate to SET2 to send my datas.
2018-06-28 09:31 AM
Thanks for the explanation. That's what I thought - I definitely would have just flipped the pin into/out of GPIO mode (with the 0 set in the ODR bit at initialization). Much quicker, much simpler.