2019-01-23 02:55 AM
Hi everyone!
How can i use my MCU STM32F407IG like a PL2303 FTDI. Like basically how can i use my mcu as a usb to uart converter? I already worked with the usb device cdc example and i send data to uart tx everything is fine an working but somehow what is working with my pl2303 is not with the mcu. What do i need to implement in my mcu code to make it work exactly like a pl2303?
2019-01-23 03:49 AM
What does working vs not working mean in this context?
The USB CDC/VCP delivers blocks of data for you to process. You need to adapt your methodology to handle data differently, using buffers and code that doesn't block in callback/interrupt context.
2019-01-23 04:15 AM
I use HAL_Transmit_DMA for transmitting every byte that is send over COM Port. I have connected another chip (HD64F2166) with rx and tx and the communication between MCU and the Chips doesnt work over USB FS but works over USB to UART with PL2303A that's my issue now. Do i have to change the example of the buffer method for transmitting data?
2019-01-23 04:23 AM
If that function blocks, I could see it failing, the CDC/VCP can also deliver multiple bytes.
I would use buffering so as not to stall real-time operation of USB.
2019-01-23 07:56 AM
static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len)
{
HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
//HAL_UART_Receive_DMA(&UartHandle,x Buf, *Len);
CDC_Transmit_FS(Buf, *Len);
return (USBD_OK);
}
That is my function and i am using the standard example cdc standalone usb device
2019-01-23 09:45 AM
HAL_UART_Transmit_DMA doesn't block, but you don't check for errors, nor handle the sequencing/completion.
It also pays no attention to the lifespan of the buffer, which one should assume vapourizers once the function returns, or at the very least assume is volatile.
If you have a lot of data you want going out a USART, queue it in a buffer, and manage dispatch in the USART IRQ handler.
2019-01-24 01:22 AM
Ok thanks another thing:
How can i transmit the data received over my UART RX Pin to vcp?