This Project is going to next in the series of previous projects. Previously i interfaced inexpensive OV7670 VGA Camera to MCU.
In this post we will overcome the 10FPS limit of frame rate caused by slow Parallel port of PIC32MZ. This version of Camera will use 4.8Gbps Cypress FX3 USB 3.0 controller, with use of this controller comes 32bit 100Mhz GPIF interface, which make it possible to easily implement 30 FPS 640x480 live video transfer.
Capability of Cypress FX3 is way higher than VGA 30FPS, but for this test project i will be limited the by the max resolution of OV7670.
Hardware Connection
FX3 has Extremely flexible 32bit 100Mhz GPIF II interface for picking up data from external application processor/Data Producer. OV7670 Connected to GPIF II with 8bit prallel bus with Hsync and Vsyn line. GPIF is driver as slave with interface clock supplied from the camera pixel clock.
Here is how camera is connected to FX3
Signal CLK is pixel clock generated by camera
GPIF interface is Driven by a state machine , Here is the state machine which i used to latch data into DMA buffers. this state machine is from cypress FX3 application note AN75779 more details about can be found in the PDF document by cypress.
Test with VLC
Firmware
Firmware as usual can be found in my github account
https://github.com/circuitvalley/Cypress-FX3-USB3
In Hardware Connection: - OV7670 has two clock PCLK and External clock. Here you mention only one clock connected GPIO16 of Fx3.
ReplyDeleteHow to interface PIXCLK,SCL,SDA of OV7670 with FX3?
ReplyDeleteExternal clock for the camera in my demo is supplied from signal generator.
DeleteCamera need external clock , either have a external oscillator or use a signal gen.
PCLK is output from camera and input to FX3. While XCLK is input to camera and not connected to FX3.
Please share pin connection(Hardware)
ReplyDeleteWhether SCL and SDA pins are used or not?
ReplyDeleteCamera SDL and SDA pins are directly connected to FX3 SDL and SDA pins
DeleteIs it required to give power supply 3.3v and gnd to OV7670?
ReplyDeleteYes camera need power.
DeleteI have following error during build the project in EZ-USB Suite and I unable to create Image file
ReplyDelete11:22:21 **** Incremental Build of configuration Default for project Firmware ****
make all
Cannot run program "make": CreateProcess error=2, The system cannot find the file specified
I guess compiler or tool chain is not properly installed.
DeleteMay I know Which tool chain or compiler used for this work?
ReplyDeleteYou need to install, Cypress EZ USB Suite It will install every thing.
DeleteI build the project, generate the image file and I load into FX3 kit using USB control Center, but I unable to view the video streaming in VLC.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteMay I know pin detail of GPIO_27 which is connected to OUTPUT1? in GPIF II designer
ReplyDeleteThat is for debugging, to probe with oscilloscope.
DeleteMay I know Debugging signal? Is it debug FV or LV or PClK or Data signal?
DeleteTo debug GPIO State machine, States with DR_GPIO drives this pin.
DeleteI unable to view the video streaming in VLC. May I know about PWDN Pin?
ReplyDeleteIs below hardware connection correct LV-> CLT_11, FV->CLT_12, data[0:7] -> DQ[0:7], pclk->pclk, i2c_sda->sda, i2c_sck -> sck. reset->CLT_5,pwdn->CLT-0.
ReplyDeleteYes this seems to be correct.
DeleteMay I know the frequency used for sensor(xclk), I used 50MHz. I unable to test with VLC.
ReplyDeleteCould you support for that?
It was 24Mhz
DeleteMay I know the above state machine for ov7670 sensor?
ReplyDeleteYes it's for ov7670
DeleteFor ov7670 timing diagram FV is low and LV is high then data are valid, but in above diagram FV and LV both are high then the data are valid. Is it matched with timing?
ReplyDeleteCamera VSYNC and HSYNC polarity is settable using a register. You can select how you want. I have sent register value in such a way that VSYNC and HSYNC both are active when data is available.
ReplyDeleteOn my other post about this camera interface to PIC32, timing diagrams are given
https://www.circuitvalley.com/2019/06/opensource-diy-usb-webcam-ov7670-ov2640-pic32-USB-UVC-Video-device-class.html
May I know register value for VSYNC and HSYNC
DeleteRegister values available in source.
DeleteIn sensor.h , why SADDR_HIGH required?
ReplyDeleteSADDR_HIGH is macro to select between different I2C camera address.
Deletefor ov7670 has one camera address 0xBA only, here why SADDR_HIGH required? for multiple sensor SADDR required.
DeleteIs register configuration for VGA 30fps?
ReplyDeleteRegister values available in source are for 30FPS
DeleteI have following error, Could you support for this?
ReplyDeleteYour input can't be opened:
VLC is unable to open the MRL 'dshow://'. Check the log for details.
Check if camera is outputting data,clock and other signal in correct order. and everything is connected properly
DeleteIn my system have usb2.0 , Is FX3USB3 cable support to usb2.0 but it device,vendor id is detected FX3(04b4:00F8).
ReplyDeleteThough USB 3.0 is backward compatible but i have not tested FW with USB2.0 , Device will be detected , what exact stream capability are implemented for USB 2.0 interface i need to look into code.
Deletewhole point of FX3 is USB 3.0 , so try with USB 3.0
Is is possible to look your interface board? i.e. connection between FX3 and Sensor.
ReplyDeleteRight now i do not have that board in my hands i will need to look for it. connections are exact as shown in the GPIF image above.
DeleteIn uvc.c, UVC Probe Control Settings for a USB 3.0 connection max.video frame size 0x00, 0x6F, 0x09, 0x00. Could you explain this?
ReplyDeletecan you please point out line number?
DeleteLine# 147 - 0x00, 0x6F, 0x09, 0x00, /* Max video frame size in bytes */
DeleteIts exactly what comments say , define how many maximum number of bytes are in one image frame. for VGA it should be larger than 640x480x2 .
Deleteabove 0x00,0x6f,0x09,0x00 for 640x483x2 Why Height is 483?
DeleteIf i remember correctly , Sensor output 3 extra lines for 640x480 resolution.
DeleteCould you explain the DBVAL(x) and WBVAL(x) line#3 and #4, Class specific uncompressed vs Frame Descriptor in cyfxuvcdscr.c
ReplyDeleteDBVAL and WBVAL are just two macro to fill constant value into arrays with correct endianness.
DeletePlease make sure LV means Href and FV means Vsync.
ReplyDeleteYes LV is href , line sync
DeleteFV is Vsync , frame sync
I tried with UART debug port and I got following log..
ReplyDeletePlease help to solve this and I didn't get video streaming...
UsbEventCB: SUSPEND encountered...
Entering USB SuspÿY‹ j½‘•5Leaving Suspend Mode
UsbEventCB: Detected HS USB Connection
UsbEventCB: SUSPEND encountered...
Entering USB Suspend Mÿ‹VVHøLeaving Suspend Mode
Application Started
DMA Reset Event: Frame timer overflow, time period = 400
Application Stopped
Application Started
I tired with USB 3.0 I didn't get video stream
ReplyDeletebelow log for USB 3.0
UsbEventCB: Detected SS USB Connection
UsbEventCB: SUSPEND encountered...
Entering USB Suspend Mÿ‹VVHøLeaving Suspend Mode
Application Started
DMA Reset Event: Frame timer overflow, time period = 200
Application Stopped
Application Started
It looks like FX3 is not getting frame sync signal from camera.
Deleteif you have an oscilloscope, could you please check all vital camera signals.
Like frame sync , line sync and pixel clock?
Please explain this How to calculate frame interval
ReplyDelete0x15, 0x16, 0x05, 0x00, /* Desired frame interval in the unit of 100ns: 30 fps */
0x2A, 0x2C, 0x0A, 0x00, /* Desired frame interval in the unit of 100ns: 15 fps */
Thanks for the post. May I please know where to connect VSYNC and HREF to Board?
ReplyDeleteVSYNC connects to LV which is line sync
DeleteHREF connects to FV which is frame sync
Thanks Gaurav for confirming this.
DeleteI can well compile and load the program to board but when testing with vlc, it detects as FX3 but nothing coming up on screen...just black screen. any suggestion, what to check more?
Hi Gaurav, May I know , How did you calculate "glFrameTimerPeriod" in case of 0v7670?
ReplyDelete