FX3SMassStorage例程中CyU3PSibQueryDevice()返回0x68

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

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

cross mob
thsh_4007911
Level 1
Level 1
First question asked First solution authored First reply posted

Hi,

     在我们的板子上通过CyUSB3035来访问MicroSD插槽(只有一个),VIO2提供3.3V电压。

     其中,MicroSD的引脚如下图:

     pastedImage_0.png

     我将FX3SMassStorage例程修改后,下载到CyUSB3035中运行,调试信息返回“StorageQueryDev (0) failed with code 0x68”。

     FX3SMassStorage例程主要修改如下:

     1、#define LOG_ENABLE

     2、int main(void)

    /* Configure the IO matrix for the device.

     * S0 port is enabled in 8 bit mode.

     * S1 port is enabled in 4 bit mode.

     * UART is enabled on remaining pins of the S1 port.

     */

    io_cfg.isDQ32Bit        = CyFalse;

    io_cfg.s0Mode           = CY_U3P_SPORT_4BIT;

#ifdef LOG_ENABLE

    /* If the UART is used for logging, we can only configure the S1 port as 4 bits wide. */

    io_cfg.s1Mode           = CY_U3P_SPORT_INACTIVE;

    io_cfg.lppMode          = CY_U3P_IO_MATRIX_LPP_UART_ONLY;

    io_cfg.useUart          = CyTrue;

#else

    io_cfg.s1Mode           = CY_U3P_SPORT_8BIT;

    io_cfg.lppMode          = CY_U3P_IO_MATRIX_LPP_NONE;

    io_cfg.useUart          = CyFalse;

#endif

    io_cfg.gpioSimpleEn[0]  = 0;

    io_cfg.gpioSimpleEn[1]  = 0;//x02102800;                       /* IOs 43, 45, 52 and 57 are chosen as GPIO. */

    io_cfg.gpioComplexEn[0] = 0;

    io_cfg.gpioComplexEn[1] = 0;

    io_cfg.useI2C           = CyFalse;

    io_cfg.useI2S           = CyFalse;

    io_cfg.useSpi           = CyFalse;

    status = CyU3PDeviceConfigureIOMatrix (&io_cfg);

    if (status != CY_U3P_SUCCESS)

    {

        goto handle_fatal_error;

    }

     3、void CyFxMscApplnSibInit (void)

    intfParams.resetGpio       = 0xFF;                          /* No GPIO control on SD/MMC power. */

    intfParams.rstActHigh      = CyTrue;                        /* Don't care as no GPIO is selected. */

    intfParams.cardDetType     = CY_U3P_SIB_DETECT_DAT_3;       /* Card detect based on SD_DAT[3]. */

    intfParams.voltageSwGpio   = 0xFF;                          /* Use GPIO_45 for voltage switch on S0 port. */

    intfParams.lvGpioState     = CyFalse;                       /* Driving GPIO low selects 1.8 V on SxVDDQ. */

    intfParams.writeProtEnable = CyFalse;                       /* Write protect handling enabled. */

    intfParams.lowVoltage      = CyFalse;                        /* Low voltage operation enabled. */

    intfParams.useDdr          = CyTrue;                        /* DDR clocking enabled. */

    intfParams.maxFreq         = CY_U3P_SIB_FREQ_104MHZ;        /* No S port clock limitation. */

    intfParams.cardInitDelay   = 0;                             /* No SD/MMC initialization delay required. */

status = CyU3PSibSetIntfParams (0, &intfParams);

if (status != CY_U3P_SUCCESS)

{

AppDebugPrint (4, "Set S0 SIB interface parameters failed, code=0x%x\r\n", status);

CyFxAppErrorHandler (status);

}

    status = CyU3PSibStart ();

    if (status != CY_U3P_SUCCESS)

    {

        AppDebugPrint (4, "SIB start failed, code=0x%x\r\n", status);

        CyFxAppErrorHandler (status);

    }

     可以识别到大容量存储设备,但是无法连接到SD卡。

0 点赞
1 解答

     由于只使用一个S0 port,所以VIO2供电3.3V,VIO3没有供电,VIO4供电1.8V。

     VIO2供电必须是3.3V,启动时必须要3.3V,如果支持低电压,则动态修改为1.8V;VIO4供电始终是1.8V,我在例程中使用串口打印调试信息,后期会使用SPI。

     现在我的板子和串口都是分别直接连接到PC的USB 3.0接口,使用FX3SFileSystem例程可以正确读写SD卡。之前我的板子和串口都是通过一个USB Hub连接到PC的,而且Hub没有外接电源,我想这是之前出现问题的主要原因。

     希望能给其他遇到类似问题的人提供帮助。

在原帖中查看解决方案

0 点赞
3 回复数
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

您好,

没有看出您的代码有明显的问题,请对照AN70707查找硬件上的原因,如DAT是否拉高。

https://www.cypress.com/documentation/application-notes/an70707-ez-usb-fx3-fx3s-hardware-design-guid...

0 点赞
thsh_4007911
Level 1
Level 1
First question asked First solution authored First reply posted

您好,

     非常感谢答复。

     1、我现在使用的是UHS-I的MicroSD卡。根据《EZ-USB® FX3™/FX3S™硬件设计指南和原理图检查表》中的13.1 S 端口接口中的描述:

pastedImage_5.png

     这意味着,我需要将VIO2改成1.8V供电,并在CyU3PSibSetIntfParams()中设置为低电压?动态修改是什么意思?

     2、卡座中的DAT3连接到GPIO 36,因此,intfParams.voltageSwGpio = 36,同时调用CyU3PDeviceGpioOverride()CyU3PGpioSetSimpleConfig(),将GPIO 36设置为Simple Input,这样设置对吗?还是说应该设置为Simple Output?

          我看到CyU3PSibInitCard()代码中,如果是低电压,先将voltageSwGpio配置为Simple Output。

     3、intfParams.lvGpioState应该如何配置呢?

0 点赞

     由于只使用一个S0 port,所以VIO2供电3.3V,VIO3没有供电,VIO4供电1.8V。

     VIO2供电必须是3.3V,启动时必须要3.3V,如果支持低电压,则动态修改为1.8V;VIO4供电始终是1.8V,我在例程中使用串口打印调试信息,后期会使用SPI。

     现在我的板子和串口都是分别直接连接到PC的USB 3.0接口,使用FX3SFileSystem例程可以正确读写SD卡。之前我的板子和串口都是通过一个USB Hub连接到PC的,而且Hub没有外接电源,我想这是之前出现问题的主要原因。

     希望能给其他遇到类似问题的人提供帮助。

0 点赞