the Callback function can not be called for uart rx dma of mode when the rx receive data

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
liuzhengxiang
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

dmaConfig.cb = CyFxUartLpDmaCallback

the CyFxUartLpDmaCallback can not be called for uart rx dma of mode when the rx receive data.The code is as follows:

CyU3PReturnStatus_t
CyCx3AppDebugInit (void)
{
CyU3PUartConfig_t uartConfig;
CyU3PDmaChannelConfig_t dmaConfig;
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

/* Initialize the UART module */
status = CyU3PUartInit ();
if (status != CY_U3P_SUCCESS)
{
/* Error handling */
CyCx3AppErrorHandler(status);
}

/* Configure the UART
Baudrate = 115200, One stop bit, No parity, Hardware flow control enabled.
*/
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 */
status = CyU3PUartSetConfig (&uartConfig, CyFxUartLpDmaCallback);
if (status != CY_U3P_SUCCESS )
{
/* Error handling */
CyCx3AppErrorHandler(status);
}

/* Create a DMA Manual channel between UART producer socket
and UART consumer socket */
CyU3PMemSet ((uint8_t *)&dmaConfig, 0, sizeof(dmaConfig));
dmaConfig.size = 16;
dmaConfig.count = 2;
dmaConfig.prodSckId = CY_U3P_LPP_SOCKET_UART_PROD;
dmaConfig.dmaMode = CY_U3P_DMA_MODE_BUFFER;
dmaConfig.notification = CY_U3P_DMA_CB_PROD_EVENT;
dmaConfig.cb = CyFxUartLpDmaCallback;
dmaConfig.prodHeader = 0;
dmaConfig.prodFooter = 0;
dmaConfig.consHeader = 0;
dmaConfig.prodAvailCount = 0;

/* Create the channel */
status = CyU3PDmaChannelCreate (&glUartRxChHandle,
CY_U3P_DMA_TYPE_MANUAL, &dmaConfig);
if (status != CY_U3P_SUCCESS)
{
/* Error handling */
CyCx3AppErrorHandler(status);
}

/* Set UART Tx and Rx transfer Size to infinite */
status = CyU3PUartRxSetBlockXfer(0xFFFFFFFF);
if (status != CY_U3P_SUCCESS)
{
/* Error handling */
CyCx3AppErrorHandler(status);
}

/* Set DMA Channel transfer size */
status = CyU3PDmaChannelSetXfer (&glUartRxChHandle, 0);
if (status != CY_U3P_SUCCESS)
{
/* Error handling */
CyCx3AppErrorHandler(status);
}

/* Initialize the debug application */
status = CyU3PDebugInit (CY_U3P_LPP_SOCKET_UART_CONS, 8);
if (status != CY_U3P_SUCCESS)
{
return status;
}

CyU3PDebugPreamble (CyFalse);

}

void CyFxUartLpDmaCallback (
CyU3PDmaChannel *chHandle, /* Handle to the DMA channel. */
CyU3PDmaCbType_t type, /* Callback type. */
CyU3PDmaCBInput_t *input) /* Callback status. */
{
CyU3PReturnStatus_t status;
gUartRecDataFlag = CyFalse;
if (type == CY_U3P_DMA_CB_PROD_EVENT)
{
/* This is a produce event notification to the CPU. This notification is
* received upon reception of every buffer. The buffer will not be sent
* out unless it is explicitly committed. The call shall fail if there
* is any application error. */

input->buffer_p.buffer[input->buffer_p.size] = '\0';
CyU3PDebugPrint (4, "%s", input->buffer_p.buffer);

status = CyU3PDmaChannelDiscardBuffer (chHandle);

if (status != CY_U3P_SUCCESS)
{
CyCx3AppErrorHandler (status);
}
}
}

The serial IO configuration is correct and the connection is correct. I've tested TX, Rx in register mode.Now I want to use DMA to receive data。but the the Callback function can not be called for uart rx dma of mode when the rx receive data.

0 Likes
1 Solution
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

我们SDK中有一个历程USBUart是以Uart到USB的DMA的方式实现的把串口的数据发送到PC,并且在PC端设备枚举为一个串口设备,您可以试一下这个例程观察是否可以收到数据。

View solution in original post

0 Likes
11 Replies