USB CDC with flow control
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-02-18 11:25 PM
Posted on February 19, 2015 at 08:25
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:- Is there a sample code which does implement UART flow control?
- How should the example code be modified to support this?
- Will switching to Cube's HAL help in this case?
Labels:
- Labels:
-
UART-USART
-
USB
This discussion is locked. Please start a new topic to ask your question.
0 REPLIES 0
