cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

New Contributor

hi,we used ov5640 with cx3,  we didn't use hard reset to reset  ov5640 sensor  ,so used soft reset  to reset sensor ,but some times the graph is green.

we add the soft rest in the Cx3UvcOV5640  demo:

here is we add the code:

void

CyCx3AppInit (

        void)

{

    ......

status =  CyU3PMipicsiInit();

    if (status != CY_U3P_SUCCESS)

    {

    LOG ("AppInit:MipicsiInit Err = 0x%x", status);

        CyCx3AppErrorHandler(status);

    }

  status = CyU3PMipicsiSetIntfParams(&cfgUvcVgaNoMclk, CyFalse);

if (status != CY_U3P_SUCCESS) {

    LOG("AppInit:MipicsiSetIntfParams Err = 0x%x", status);

    CyCx3AppErrorHandler(status);

}

status = CyU3PMipicsiSetSensorControl(CY_U3P_CSI_IO_XRES, CyTrue);  //soft rest

.....

}

how can we solve  this problems? is the soft reset should be used on other palce ?   the same code runs on development board  as well.

1png.png2.png

0 Likes
Reply
1 Solution
Moderator
Moderator

Hello,

As the default firmware steams YUY2 format, the greenish color in the video is because the chrominance component of YUY2 format is all 1's. This can be due to noise as you said the board is not stable. Please confirm that the color format is same in your firmware

Please refer to this KBA CX3 Hardware: Frequently Asked Questions - KBA91295 which mentions the hardware guidelines to be followed while designing board with CX3 and confirm that all of the guidelines are followed.

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
Reply
7 Replies
Moderator
Moderator

Hello,

Please let me know is the default firmware OV5640 works fine with the same board.

Also, are you using the Denebola kit or some custom board for testing this firmware? What are the results while testing on both boards?

Please let me know where is CyCx3_ImageSensor_Init(); called in the firmware. Meanwhile I will try reproducing the same problem at my end.

Regards,

Rashi

Regards,
Rashi
0 Likes
Reply
New Contributor

hi.

the default firmware OV5640 works run on the same board then on graph can show out ,becase the board has no hard rest to image sensor,so we need software reset to make image sensor to show image.

we used our customer board test the framework,also we run the same framework on development board but it runs well and our custom board is unstable.

customer board is designed according to the principle of development board,the only different is customer has no hardware rest function.

and here is the appInit code:

void

CyCx3AppInit (

void)

{

CyU3PEpConfig_t endPointConfig;

CyU3PDmaMultiChannelConfig_t dmaCfg;

CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

#ifdef CX3_DEBUG_ENABLED

CyU3PMipicsiCfg_t readCfg;

CyU3PMipicsiErrorCounts_t errCnts;

#endif

/* Initialize the I2C interface for Mipi Block Usage and Camera. */

status = CyU3PMipicsiInitializeI2c (CY_U3P_MIPICSI_I2C_400KHZ);

if(status != CY_U3P_SUCCESS)

{

LOG ("AppInit:I2CInit Err = 0x%x.",status);

CyCx3AppErrorHandler(status);

}

/* Initialize GPIO module. */

status = CyU3PMipicsiInitializeGPIO ();

if( status != CY_U3P_SUCCESS)

{

LOG ("AppInit:GPIOInit Err = 0x%x",status);

CyCx3AppErrorHandler(status);

}

/* Initialize the PIB block */

status = CyU3PMipicsiInitializePIB ();

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:PIBInit Err = 0x%x",status);

CyCx3AppErrorHandler(status);

}

//enable camera

//initCameraPwrEn();

//CyU3PThreadSleep(10);

/* Start the USB functionality */

status = CyU3PUsbStart();

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:UsbStart Err = 0x%x",status);

CyCx3AppErrorHandler(status);

}

/* The fast enumeration is the easiest way to setup a USB connection,

  • where all enumeration phase is handled by the library. Only the

  • class / vendor requests need to be handled by the application. */

CyU3PUsbRegisterSetupCallback(CyCx3AppUSBSetupCB, CyTrue);

/* Setup the callback to handle the USB events */

CyU3PUsbRegisterEventCallback(CyCx3AppUSBEventCB);

/* Register a callback to handle LPM requests from the USB 3.0 host. */

CyU3PUsbRegisterLPMRequestCallback (CyCx3AppLPMRqtCB);

/* Set the USB Enumeration descriptors */

/* Super speed device descriptor. */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_DEVICE_DESCR, 0, (uint8_t *)CyCx3USB30DeviceDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_SS_Device_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* High speed device descriptor. */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_DEVICE_DESCR, 0, (uint8_t *)CyCx3USB20DeviceDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_HS_Device_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* BOS descriptor */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_BOS_DESCR, 0, (uint8_t *)CyCx3USBBOSDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_BOS_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* Device qualifier descriptor */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_DEVQUAL_DESCR, 0, (uint8_t *)CyCx3USBDeviceQualDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_DEVQUAL_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* Super speed configuration descriptor */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_CONFIG_DESCR, 0, (uint8_t *)CyCx3USBSSConfigDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_SS_CFG_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* High speed configuration descriptor */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_CONFIG_DESCR, 0, (uint8_t *)CyCx3USBHSConfigDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_HS_CFG_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* Full speed configuration descriptor */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_FS_CONFIG_DESCR, 0, (uint8_t *)CyCx3USBFSConfigDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_FS_CFG_Dscr Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 0 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 0, (uint8_t *)CyCx3USBStringLangIDDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr0 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 1 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 1, (uint8_t *)CyCx3USBManufactureDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr1 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 2 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 2, (uint8_t *)CyCx3USBProductDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr2 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 3 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 3, (uint8_t *)CyCx3USBConfigSSDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr3 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 4 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 4, (uint8_t *)CyCx3USBConfigHSDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr4 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* String descriptor 5 */

status = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 5, (uint8_t *)CyCx3USBConfigFSDscr);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:Set_STRNG_Dscr5 Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* We enable device operation off VBat and use the VBatt signal for USB connection detection. This is the standard

  • setting for all CX3 designs, as the VBus and VBatt signals are connected to a single pad.

*/

CyU3PUsbVBattEnable (CyTrue);

CyU3PUsbControlVBusDetect (CyFalse, CyTrue);

/* Control status interrupt endpoint configuration:

We are not actually using the endpoint, and only leaving it enabled so that any requests will be NAKed.

*/

endPointConfig.enable = 1;

endPointConfig.epType = CY_U3P_USB_EP_INTR;

endPointConfig.isoPkts = 1;

endPointConfig.streams = 0;

endPointConfig.pcktSize = CX3_EP_INTR_PACKET_SIZE;

endPointConfig.burstLen = CX3_EP_INTR_BURST_LEN;

status = CyU3PSetEpConfig(CX3_EP_CONTROL_STATUS, &endPointConfig);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:CyU3PSetEpConfig CtrlEp Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/* Setup the Bulk endpoint used for Video Streaming:

Always configure the endpoint with SuperSpeed parameters. The FX3 library will make adjustments as required.

*/

endPointConfig.enable = CyTrue;

endPointConfig.epType = CY_U3P_USB_EP_BULK;

endPointConfig.isoPkts = 0;

endPointConfig.streams = 0;

endPointConfig.pcktSize = CX3_EP_BULK_VIDEO_PKT_SIZE;

endPointConfig.burstLen = CX3_EP_BULK_SUPER_SPEED_BURST_LEN;

status = CyU3PSetEpConfig(CX3_EP_BULK_VIDEO, &endPointConfig);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:CyU3PSetEpConfig BulkEp Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

CyU3PUsbEPSetBurstMode (CX3_EP_BULK_VIDEO, CyTrue);

/* Create a DMA Manual OUT channel for streaming data */

/* Video streaming Channel is not active till a stream request is received */

dmaCfg.size = CX3_APP_STREAM_BUF_SIZE;

dmaCfg.count = CX3_APP_STREAM_BUF_COUNT;

dmaCfg.validSckCount = CX3_APP_SOCKET_COUNT;

dmaCfg.prodSckId[0] = CX3_PRODUCER_PPORT_SOCKET_0;

dmaCfg.prodSckId[1] = CX3_PRODUCER_PPORT_SOCKET_1;

dmaCfg.consSckId[0] = CX3_EP_VIDEO_CONS_SOCKET;

dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;

dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;

dmaCfg.cb = CyCx3AppDmaCallback;

dmaCfg.prodHeader = CX3_APP_PROD_HEADER;

dmaCfg.prodFooter = CX3_APP_PROD_FOOTER;

dmaCfg.consHeader = 0;

dmaCfg.prodAvailCount = 0;

status = CyU3PDmaMultiChannelCreate (&glChHandleUVCStream, CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE , &dmaCfg);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:DmaMultiChannelCreate Err = 0x%x", status);

}

/* Configure the Fixed Function GPIF on the CX3 to use a 16 bit bus, and

  • a DMA Buffer of size CX3_APP_DATA_BUF_SIZE

*/

status = CyU3PMipicsiGpifLoad(CY_U3P_MIPICSI_BUS_16, CX3_APP_DATA_BUF_SIZE);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:MipicsiGpifLoad Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

CyU3PGpifRegisterSMIntrCallback (CyCx3AppGpifCB);

/* Initialize the MIPI block */

LOG("begin CyU3PMipicsiInit...");

status = CyU3PMipicsiInit();

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:MipicsiInit Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

status = CyU3PMipicsiSetIntfParams(&cfgUvcVgaNoMclk, CyFalse);

if (status != CY_U3P_SUCCESS) {

LOG("AppInit:MipicsiSetIntfParams Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/**here is we add the code to do software reset */

LOG("begin CyU3PMipicsiSetSensorControl...");

status = CyU3PMipicsiSetSensorControl(CY_U3P_CSI_IO_XRES, CyTrue);

if (status != CY_U3P_SUCCESS)

LOG("CyU3PMipicsiSetSensorControl failed..... 0x%x", status);

#if 1

CyU3PMipicsiCfg_t read;

status = CyU3PMipicsiQueryIntfParams (&read);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:MipicsiQueryIntfParams Err = 0x%x",status);

CyCx3AppErrorHandler(status);

}

CyU3PMipicsiErrorCounts_t errCnt;

status = CyU3PMipicsiGetErrors (CyFalse, &errCnt);

#endif

/* Setup Image Sensor */

status = CyCx3_ImageSensor_Init();

if (status != CY_U3P_SUCCESS)

LOG("CyCx3_ImageSensor_Init failed.....0x%x", status);

status = CyCx3_ImageSensor_Sleep();

if (status != CY_U3P_SUCCESS)

LOG("CyCx3_ImageSensor_Sleep failed.....0x%x", status);

#ifdef RESET_TIMER_ENABLE

CyU3PTimerCreate (&Cx3ResetTimer, CyCx3AppProgressTimer, 0x00, TIMER_PERIOD, 0, CYU3P_NO_ACTIVATE);

#endif

/* Connect the USB pins and enable super speed operation */

status = CyU3PConnectState (CyTrue, CyTrue);

if (status != CY_U3P_SUCCESS)

{

LOG ("AppInit:ConnectState Err = 0x%x", status);

CyCx3AppErrorHandler(status);

}

/*CyU3PThreadSleep(100);

status = CyU3PMipicsiSetSensorControl(CY_U3P_CSI_IO_XRES, CyTrue);

if (status != CY_U3P_SUCCESS)

LOG("CyU3PMipicsiSetSensorControl failed.....");*/

//init display

init_display(CyFalse);

//init imu

/*status = init_imu_bno_080();

if(status != CY_U3P_SUCCESS)

{

LOG ("init_imu_bno_080 failed 0x%x", status);

}*/

//imu

float value;

status = BNO080_Initialization();

if (status != CY_U3P_SUCCESS)

LOG ("BNO080_Initialization Err = 0x%x", status);

enableRotationVector(2500); //enable rotation vector at 400Hz

}

0 Likes
Reply
Moderator
Moderator

Hello,

I observed that sensor rest is done twice in the code snippet that you have shared. Please try calling sensor rest before initializing the sensor.

snip_reset.PNG

I have tested the modified firmware with Denebola Kit and it works fine. (results attached). Please call the sensor reset API only once and try.

As you mentioned the custom board is unstable. Please confirm the greenish video is seen when testing on custom board.

Regards,

Rashi

Regards,
Rashi
0 Likes
Reply
New Contributor

Hi,

my code didn't rest twice , the last reset code has been commented out ,and our code can run well on Denebola Kit .

0 Likes
Reply
Moderator
Moderator

Hello,

Thanks for the update.

Then it seems that the problem is not because of calling reset API. There can be a problem with the custom board and not from the firmware side. It seems some kind of noise is added to the video data.

Please refer to this thread FX3 with AN75779 source code and MT9M114, color modification with a similar problem but with FX3 and not CX3.

Please test default OV5640 firmware with the custom board and share the results. Is 1.png (from your previous response) results when tested on the custom board?

Regards,

Rashi

Regards,
Rashi
0 Likes
Reply
New Contributor

Hi:

There is nothing can be showed if the default OV5640 firmware run on customer board,all the uvc app video and graph always black ,so that's why we must need software reset api to resolve this problem.

0 Likes
Reply
Moderator
Moderator

Hello,

As the default firmware steams YUY2 format, the greenish color in the video is because the chrominance component of YUY2 format is all 1's. This can be due to noise as you said the board is not stable. Please confirm that the color format is same in your firmware

Please refer to this KBA CX3 Hardware: Frequently Asked Questions - KBA91295 which mentions the hardware guidelines to be followed while designing board with CX3 and confirm that all of the guidelines are followed.

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
Reply