2015-02-18 11:25 PM
The example provided for Virtual COM over USB (STM32_USB-FS-Device_Lib_V4.0.0\Projects\Virtual_COM_Port) does not include UART flow control. The UART module is hard-coded to not use CTS/RTS, and when the UART-->USB buffer overflows, the head pointer is set to 0, running over previous data:
hw_config.c:
bool USART_Config(void){ ... ... USART_BaudRate = linecoding.bitrate; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* Configure and enable the USART */ STM_EVAL_COMInit(COM1, &USART_InitStructure); return (TRUE);}void USART_To_USB_Send_Data(void){ ...USART_Rx_Buffer[USART_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1);
... USART_Rx_ptr_in++; /* To avoid buffer overflow */ if(USART_Rx_ptr_in == USART_RX_DATA_SIZE) { USART_Rx_ptr_in = 0; // <-- no flow control }}Questions: