I generated USB VCP code for "STM32F103C8T6" with STM32CubeMX. I'm trying to send received data by STM from PC, to an Arduino board using UART. The code works good for data with little size, but when I want to send bigger data the received data in Arduino is corrupted. I'm using "Teraterm" and "Realterm" for sending data from PC to STM32.
I modified the CDC_Receive_FS
for sending data via UART in DMA mode, here is the code:
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
HAL_UART_Transmit_DMA(&huart3, Buf,(uint16_t)* Len);/* same problem with HAL_UART_Transmit_IT*/
USBD_CDC_ReceivePacket(hUsbDevice_0);//Getting ready for receiving next data
return (USBD_OK);
}
I sent this
{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40}
and received
{1 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 20 21 22 23 24 2}
The USART baud rate is 19200, and in STM32, size of Received buffer, APP_RX_DATA_SIZE
is defined 640.
What should I do?