2016-10-11 11:46 PM
Hello all,
I'm using the ST Library for USB Communication via VCP and as CDC Device.Now I'm trying to flush the buffer, when the µC recieves a ''p'' from the PC. I already tried to set APP_Rx_ptr_in and APP_Rx_ptr_outto 0, but this has no effect.How can I flush the buffer properly? Thanks for any advice! Mark Edit: I tried something different, should this do the job?USB_OTG_CORE_HANDLE USB_OTG_dev;
void FlushFifo(void)
{
USB_OTG_FlushTxFifo(&USB_OTG_dev, 0x10); /* all Tx FIFOs */
USB_OTG_FlushRxFifo(&USB_OTG_dev);
}
2016-10-12 04:06 AM
Hiwer.mark,
Use the following function in STM32Fxx_ll_Usb. file:/* Flush a Tx FIFO */
USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num )
/* Flush Rx FIFO */
USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx)
-Hannibal-
2016-10-12 07:37 AM
Hi Hannibal,
unfortunately these functions are not available in the library I use.2016-10-12 08:42 AM
Hi wer.mark,
To get help in the forum , you would give more details: wich device ? which hardware ? application purpuse? Whcih driver/ library versions? share you code or taget parts .-Hannibal-2016-10-12 10:39 PM
Hi Hannibal,
I'm using a STM32F4 Discovery Board to measure the time between two edges. The library is based on the STM32_USB-Host-Device_Lib_V2.2.0 library. The buffer should be cleared when I press ''p'' on the keyboard, because sometimes when I press ''s'' to start the measurement again there are still old values which i recieve.Thanks in advance2016-10-17 06:30 AM
Hi wer.mark,
Are using DMA/ interrupt or polling for UART receive ?Try to Clear the UART ORE pending flag before receive data.Try to get help from the description in the driver on top''[..]
In this Mode it is advised to use the following functions:
(+) void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState);
(+) ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
(+) void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);
*** DMA Mode ***
================
[..]
In DMA Mode, the USART communication can be managed by 2 DMA Channel requests:
(#) USART_DMAReq_Tx: specifies the Tx buffer DMA transfer request
(#) USART_DMAReq_Rx: specifies the Rx buffer DMA transfer request
[..]
In this Mode it is advised to use the following function:
(+) void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);-Hannibal-