- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my project,I need to use CyU3PUartTransmitBytes Transmit some raw data to my device by UART ,
The API say that the function can only be used on configured for register(non-DMA) transfer mode.
so I set uartConfig.isDma to CyFalse,
But it will lead to the FX3 firmware is not start-up successfully. I don't know where the FX3 firmware is going.
Can you please help me review the code?
For your reference, I also post my related code.
static void
CyFxUVCApplnDebugInit (
void)
{
CyU3PUartConfig_t uartConfig;
CyU3PReturnStatus_t apiRetStatus;
/* Initialize the UART for printing debug messages */
apiRetStatus = CyU3PUartInit ();
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "UART initialization failed!\n");
CyFxAppErrorHandler (apiRetStatus);
}
/* Set UART Configuration */
uartConfig.baudRate = CY_U3P_UART_BAUDRATE_115200;
uartConfig.stopBit = CY_U3P_UART_ONE_STOP_BIT;
uartConfig.parity = CY_U3P_UART_NO_PARITY;
uartConfig.txEnable = CyTrue;
uartConfig.rxEnable = CyFalse;
uartConfig.flowCtrl = CyFalse;
uartConfig.isDma = CyFalse;
/* Set the UART configuration */
apiRetStatus = CyU3PUartSetConfig (&uartConfig, NULL);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyFxAppErrorHandler (apiRetStatus);
}
/* Set the UART transfer */
apiRetStatus = CyU3PUartTxSetBlockXfer (0xFFFFFFFF);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyFxAppErrorHandler (apiRetStatus);
}
/* Initialize the Debug logger module. */
apiRetStatus = CyU3PDebugInit (CY_U3P_LPP_SOCKET_UART_CONS, 4);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyFxAppErrorHandler (apiRetStatus);
}
/* Disable log message headers. */
CyU3PDebugPreamble (CyFalse);
}
int
main (
void)
{
CyU3PReturnStatus_t apiRetStatus;
CyU3PIoMatrixConfig_t io_cfg;
CyU3PSysClockConfig_t clkCfg;
/* setSysClk400 clock configurations */
clkCfg.setSysClk400 = CyTrue; /* FX3 device's master clock is set to a frequency > 400 MHz */
clkCfg.cpuClkDiv = 2; /* CPU clock divider */
clkCfg.dmaClkDiv = 2; /* DMA clock divider */
clkCfg.mmioClkDiv = 2; /* MMIO clock divider */
clkCfg.useStandbyClk = CyFalse; /* device has no 32KHz clock supplied */
clkCfg.clksrc=CY_U3P_SYS_CLK; /* Clock source for a peripheral block */
/* Initialize the device */
apiRetStatus = CyU3PDeviceInit (&clkCfg);
if (apiRetStatus != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}
/* Turn on instruction cache to improve firmware performance. Use Release build to improve it further */
apiRetStatus = CyU3PDeviceCacheControl (CyTrue, CyFalse, CyFalse);
/* Configure the IO matrix for the device. */
io_cfg.isDQ32Bit = CyFalse;
io_cfg.lppMode = CY_U3P_IO_MATRIX_LPP_DEFAULT;
io_cfg.gpioSimpleEn[0] = 0;
io_cfg.gpioSimpleEn[1] = (GPIOSIMPLEEN_1(NCONFIG) |
GPIOSIMPLEEN_1(PS_SWITCH)|
GPIOSIMPLEEN_1(NSTATUS)|
GPIOSIMPLEEN_1(NCE)|
GPIOSIMPLEEN_1(CFG_DONE)|
GPIOSIMPLEEN_1(SENSOR_RESET_GPIO)|
GPIOSIMPLEEN_1(SENSOR_STANDBY));
io_cfg.gpioComplexEn[0] = 0;
io_cfg.gpioComplexEn[1] = 0;
io_cfg.useUart = CyTrue; /* Uart is enabled for logging. */
io_cfg.useI2C = CyTrue; /* I2C is used for the sensor interface. */
io_cfg.useI2S = CyFalse;
io_cfg.useSpi = CyTrue;
apiRetStatus = CyU3PDeviceConfigureIOMatrix (&io_cfg);
if (apiRetStatus != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}
dwDie1 = CY_U3P_EFUSE_DIE_ID0;
dwDie2 = CY_U3P_EFUSE_DIE_ID1;
CyU3PKernelEntry ();
/* Dummy return to make the compiler happy */
return 0;
handle_fatal_error:
/* Cannot recover from this error. */
while (1);
}
Thanks,
Xiaodong.xu
Solved! Go to Solution.
- Labels:
-
USB Superspeed Peripherals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please check if API CyU3PDebugInit passes. As you have changed the UART configuration to register mode, CyU3PDebugInit should not be called as it uses UART in DMA mode.
So, please comment off CyU3PDebugInit API and let me know if the device enumerates successfully.
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I also try to disable the call " apiRetStatus = CyU3PUartTxSetBlockXfer (0xFFFFFFFF);" But get the same result.
I'm using the sdk1.3.3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please check if API CyU3PDebugInit passes. As you have changed the UART configuration to register mode, CyU3PDebugInit should not be called as it uses UART in DMA mode.
So, please comment off CyU3PDebugInit API and let me know if the device enumerates successfully.
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, comment off CyU3PDebugInit API then the device enumerates successfully.
if UART configuration to register mode, if call CyU3PDebugInit , it will not return?
I have comment off CyFxAppErrorHandler (apiRetStatus).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
You can check the return status of the CyU3PDebugInit API to know the reason of failure.
As the following code snippet is related to the Debug channel (DMA channel) created using CyU3PDebugInit, it can be commented off while using UART in register mode.
apiRetStatus = CyU3PDebugInit (CY_U3P_LPP_SOCKET_UART_CONS, 4);
if (apiRetStatus != CY_U3P_SUCCESS)
{
CyFxAppErrorHandler (apiRetStatus);
}
/* Disable log message headers. */
CyU3PDebugPreamble (CyFalse);
Please let me know if the problem is resolved after commenting out the above code snippet.
Rashi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#define GPIOSIMPLEEN_1(GPIOID) (1 << (GPIOID - 32))
#define NCE (57)
#define NSTATUS (43)
#define FPGA_RST (42)
#define PS_SWITCH (33)
#define CFG_DONE (50)
#define SENSOR_STANDBY (36)