cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

bbfe_4086196
New Contributor

Hi,

My problem is after configure uart dma rx transfer mode, i got every byte is zero in call back. my code is as below:

CyU3PReturnStatus_t

CyFxUartApplnInit (void)

{

CyU3PDmaChannelConfig_t dmaConfig;

CyU3PUartConfig_t uartConfig;

CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

rst_cpld();

    apiRetStatus = CyU3PUartInit ();

    if (apiRetStatus != CY_U3P_SUCCESS)

    {

        CyFxAppErrorHandler(apiRetStatus);

    }

    CyU3PMemSet ((uint8_t *)&uartConfig, 0, sizeof(uartConfig));

    uartConfig.baudRate = CY_U3P_UART_BAUDRATE_2M;

    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 */

    apiRetStatus = CyU3PUartSetConfig (&uartConfig, NULL);

    if (apiRetStatus != CY_U3P_SUCCESS )

    {

        CyFxAppErrorHandler(apiRetStatus);

    }

CyU3PMemSet ((uint8_t *)&dmaConfig, 0, sizeof(dmaConfig));

dmaConfig.size = 192;

dmaConfig.count = 4;

dmaConfig.prodSckId = CY_U3P_LPP_SOCKET_UART_PROD;

dmaConfig.consSckId = CY_U3P_CPU_SOCKET_CONS;

dmaConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;

dmaConfig.notification = CY_U3P_DMA_CB_PROD_EVENT;

dmaConfig.cb = CyFxUacMicDmaCallback;

dmaConfig.prodHeader = 0;

dmaConfig.prodFooter = 0;

dmaConfig.consHeader = 0;

dmaConfig.prodAvailCount = 0;

apiRetStatus = CyU3PDmaChannelCreate (&glUartRXChHandle,

CY_U3P_DMA_TYPE_MANUAL_IN, &dmaConfig);

if (apiRetStatus != CY_U3P_SUCCESS)

{

CyFxAppErrorHandler(apiRetStatus);

return apiRetStatus;

}

apiRetStatus = CyU3PUartTxSetBlockXfer(0xFFFFFFFF);

if (apiRetStatus != CY_U3P_SUCCESS)

{

CyFxAppErrorHandler(apiRetStatus);

}

apiRetStatus = CyU3PUartRxSetBlockXfer(0xFFFFFFFF);

if (apiRetStatus != CY_U3P_SUCCESS)

{

CyFxAppErrorHandler(apiRetStatus);

}

apiRetStatus = CyU3PDmaChannelSetXfer (&glUartRXChHandle, 0);

    if (apiRetStatus != CY_U3P_SUCCESS)

    {

        return apiRetStatus;

    }

#if 0

/* Initialize the debug module. */

apiRetStatus = CyU3PDebugInit (CY_U3P_LPP_SOCKET_UART_CONS, 8);

if (apiRetStatus != CY_U3P_SUCCESS)

{

CyFxAppErrorHandler(apiRetStatus);

}

CyU3PDebugPreamble (CyFalse);

#endif

return apiRetStatus;

}

Callback code:

static void

CyFxUacMicDmaCallback(

CyU3PDmaChannel   *chHandle, /* Handle to the DMA channel. */

CyU3PDmaCbType_t   type,     /* Callback type.             */

CyU3PDmaCBInput_t *input)    /* Callback status.           */

{

if (type == CY_U3P_DMA_CB_PROD_EVENT && recording == CyTrue) {

nprintf("%d-> %x %x %x %x\r\n",

input->buffer_p.count,

input->buffer_p.buffer[52],

input->buffer_p.buffer[43],

input->buffer_p.buffer[74],

input->buffer_p.buffer[95]);

CyU3PEventSet(&glMicEvent, MIC_EVENT, CYU3P_EVENT_OR);

}

}

from the log (send back to pc via vcom port), data always be zero, length is correct

192-> 0 0 0 0

but from logic analyzer the data is not zero.

aa.png

Is there anything wrong in configuration ? thanks.

0 Likes
1 Reply
Rashi_Vatsa
Moderator
Moderator

Hello,

Please let me know to which CX3 pin are you sending the UART data

Also, let me know the IO matrix configuration (set using CyU3PDeviceConfigureIOMatrix API) used in your firmware.

Please try this test

- Try sending only 192 bytes to UART RX pin (GPIO [49]) of CX3

- Set an event in DMA callback using CyU3PEventSet

- Get event using CyU3PEventGet in Thread Entry function

- Get the buffer using CyU3PDmaChannelGetBuffer and print the buffer values

Regards,

Rashi

Regards,
Rashi
0 Likes