One of the new features that can be found on the FRDM-K82F is the FlexIO header. It’s be specifically designed to interface with the very cost-efficient OV7670 camera, and uses 8 FlexIO lines to read data from the camera. By using the FlexIO feature, it makes it easy to connect a camera to a Kinetis MCU. A demo is included with Kinetis SDK 1.3 which streams the video data from the camera to a host computer over USB.
FlexIO:
The FlexIO is a highly configurable module found on select Kinetis devices which provides a wide range of functionality
including:
• Emulation of a variety of serial/parallel communication protocols
• Flexible 16-bit timers with support for a variety of trigger, reset, enable and disable conditions
• Programmable logic blocks allowing the implementation of digital logic functions on-chip and configurable interaction of internal and external modules
• Programmable state machine for offloading basic system control functions from CPU
All with less overhead than software bit-banging, while allowing for more flexibility than dedicated IP.
Running the Demo:
First you’ll need to setup the hardware. An 18 pin header needs to be installed on the *back* of the board. The camera is oriented this way to allow for use of shields on the top, even if the camera is being used. This way the functionality could be extended with WiFi or LCD shields.
After the header is soldered on, plug in the camera. It will look like the following when complete:
Next we need to program the K82 device with the example firmware. The software can be found in the Kinetis SDK FRDM-K82F stand-alone release, in the C:\Freescale\KSDK_1.3.0_K82\examples\frdmk82f\demo_apps\usb\device\video\flexio_ov7670 folder.
Open the project, compile, and program the example specific for your compiler like done for other examples. Make sure you also compile the USB Device library as well.
After programming the K82, unplug the USB cable from J5 (OpenSDA) and plug it into J11 (K82 USB). The board will enumerate as a generic USB video device called “USB VIDEO DEMO”. You can then use this device with any video capture software, like Skype or Lync. Here's a shot of the clock in my cube:
The resolution is 160*120, the video image format is RGB565. You may need to manually adjust the focus by rotating the lens on the camera.
The frame rate can also be sped up by modifying line 342 in usb_descriptor.c:
5fps: 0x80,0x84,0x1E,0x00, /* Default frame interval is 5fps */
10fps: 0x40,0x42,0x0F,0x00,
15fps: 0x2A,0x2C,0x0A,0x00,
20fps: 0x20,0xA1,0x07,0x00,
The 160*120 max resolution was determined by the amount internal SRAM of the device, as there is not external RAM on the FRDM-K82F board.
More Information:
Hello, thanks for sharing this great demo!
I've soldered my OV7670 module in FRDM-K82F, builded the project and all the libs in KDS, flashed it to target and I can see the USB VIDEO DEMO device on my Window's device manager, but when I open Skype, It shows that it canot find a webcam.Seem that it tries to get frames from the USB VIDEO DEMO device, but as it don't get any, it shows this message:
I tried it in 2 Windows machines (one with Windows 7 and other with Windows 10)
Debugging a little bit more, I can see activity in PCLK, XCLK, HREF, VSYNC and data pins. The RESET pin is in 3.3V and the PWDN pin is in 1V ( I had to modify the software initialization to put it in 0V, as it was not initialized in the demo software). Seems that everything is correctly soldered.
Do you know what can be wrong?
Thank you!
I got it working using GraphEdit
Great demo, Anthony!
Hello Anthony,
Could you tell me if it's possible take a picture and identify some letters or numbers with this microcontroller?
I need to take a picture, format in a valid format(like jpeg, bmp etc) and send that image from another interface, like uart etc..
Best regards
Bruno.