From the description, i understood that UART to USB channel should be created in DMA mode. Is this right?
1) DMA Mode
Please refer to usbuart (SDK installation path\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbuart) example in the SDK 1.3.4 which implements DMA channel between UART (producer) and USB (consumer)
The DMA channel is configured as shown
/* Create a DMA_AUTO channel between usb producer socket and uart consumer socket */
dmaCfg.size = size; // Size of DMA buffer
dmaCfg.count = CY_FX_USBUART_DMA_BUF_COUNT; // count of DMa buffer
dmaCfg.prodSckId = CY_FX_EP_PRODUCER1_SOCKET; // UART socket
dmaCfg.consSckId = CY_FX_EP_CONSUMER1_SOCKET; // USB socket
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
dmaCfg.notification = 0;
dmaCfg.cb = NULL;
dmaCfg.prodHeader = 0;
dmaCfg.prodFooter = 0;
dmaCfg.consHeader = 0;
dmaCfg.prodAvailCount = 0;
apiRetStatus = CyU3PDmaChannelCreate (&glChHandleUsbtoUart,
if (apiRetStatus != CY_U3P_SUCCESS)
Note: The consumer socket can be changed from USB (if not needed) to any other peripheral socket
As this is AUTO DMA channel the data received from UART will directly be committed to USB without any CPU intervention. The data received by UART will only be committed when the DMA buffer is full (that will depend on dmaCfg.size = size; ). If data needs to be sent directly as soon as it is received CyU3PDmaChannelSetWrapUp (&glChHandleUarttoUsb); API is called in this example (inside this function USBUARTAppThread_Entry) which commits partially filled DMA buffer to the USB (consumer) socket.
2) Register Mode
In the examples there is a "CyFx3BootUartDmaXferData" and "CyFx3BootUartDmaXferData" function. But in SDK 1.3.3 I can not find those... How can I send messages in DMA mode via UART?
>> These API's are boot API which can be used in the second stage bootloader. For transfers in register mode you can refer to UartLpRegMode example in the SDK (C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxuartlpregmode). Where CyU3PUartTransmitBytes and CyU3PUartReceiveBytes are used for UART data transfers through register mode.
This API CyU3PUartSetTimeout can be used to for timeout setting for the CyU3PUartTransmitBytes and CyU3PUartReceiveBytes operations is based on the number of loop iterations used while waiting for the transfer completion. Each loop iteration will require two times the period of the UART clock. The default timeout is set to 0xFFFFF and can be changed using this API. The API keeps the CPU spinning until the data transfer is completed, or the specified timeout period has elapsed. Therefore, it is not desirable to set a very large timeout for these operations.
Please let me know if any queries on this
Adding to my previous response
Is it possible during operation to change into Reg mode before using the TransmitBytes function and after that change back to DMA mode waiting for a response?
>> After the transfer/operation gets completed you can change the uart configuration by calling.
CyU3PMemSet ((uint8_t *)&uartConfig, 0, sizeof(uartConfig));
uartConfig.baudRate = CY_U3P_UART_BAUDRATE_115200;
uartConfig.stopBit = CY_U3P_UART_ONE_STOP_BIT;
uartConfig.parity = CY_U3P_UART_NO_PARITY;
uartConfig.flowCtrl = CyFalse;
uartConfig.txEnable = CyTrue;
uartConfig.rxEnable = CyTrue;
uartConfig.isDma = CyTrue; /* DMA mode */
/* Set the UART configuration */
apiRetStatus = CyU3PUartSetConfig (&uartConfig, CyFxUartLpApplnCallback);
if (apiRetStatus != CY_U3P_SUCCESS )
/* Error handling */
Uart can be configured in DMA mode after reg mode by settings the art configured as mentioned above.
Note: This can be done after the data transfer is completed i.e. either by DMA mode or register mode otherwise there would be data loss if switching is done before data transfer completes
It would only be necessary for an ACK or something like this.
>> Can you please restate this to understand your question better.