Wednesday, June 19, 2019

OpenSource DIY USB Webcam: OV7670 OV2640 Interfacing With PIC32MZ Streaming Video over USB Video Device class UVC Device

This project is going to extension to my previous project in which i implemented USB Video device class onto Microchip PIC32 USB stack.  Last project i showed how once can transmit static image over USB UVC , now i will be showing you how you can interface these commonly available  VGA/UXGA Sensors OV7670/OV2640 to PIC32MZ MCU.

Friday, May 31, 2019

Implementing USB Video Device Class (UVC) Device Driver on Microchip USB Stack, PIC32

I was recently working on a little project in which i need to stream video from mcu to PC, so i decided to look for a solution. My first obvious solution was to make a custom protocol over USB bulk or isochronous Transfer and also make some application in Qt or MATLAB to stream and display video.

But when i looked little bit more , I found out that there is already a USB video class assigned for this specific task. Driver for UVC device are already standard and present in many well used OS. Driver is present in Windows and Linux both.

As Video over USB is quite resource intensive task so it is not common to use a MCU,  I was using PIC32 MCU for project, and USB stack Provided by microchip was no exception, Microchip USB stack does not have support for UVC. So i decided to implement my self.

This project will be multi part project ,
in First part i will have static image 160x120 pixel resolution, stream over the USB and play in VLC.
Second Part i will interface a OV7670 camera to the MCU and stream live video on VLC.

A Sample image 160x120 Pixel converted to yuy2 , Streamed over USB played on VLC

Monday, April 22, 2019

Zwei2: OpenSource Breadboardable Microchip PIC32MZ Board USB

Quite often i use PIC32 microcontrollers in my project, and as since quite some time PIC32MZ microcontrollers are there, with improved features such as USB HS and much more . i was not able to find a board which exactly fits my needs. so i made my self this little board ,i call it Zwei^2 , it is quite small,and can be put onto a breadboard.

Sunday, April 7, 2019

PIC32MX DMA Performance Test , PMP Parallel Master Port DMA Performance (Specifically PIC32MX470F512H)

This is going to be Quick Post showing Maximum Possible Performance of DMA in PIC32MX MCU, These tests are performed with PIC32MX470F512H running at 120Mhz

Short answer:
if you do not want to read further than. My result show DMA can perform 32bit transfers at rate of maximum 10Mhz. This result is quite similar to few other article on web, I do not have answer what exactly limit the maximum transfer rate to 10Mhz, but actual achievable transfer rate may vary depending on the System Bus availability,  As System bus is shared between all DMA , CPU and other peripheral.

I have also tried to trigger transfer from timer and external interrupt , any trigger rate above 10Mhz start skipping transfers,

As rule of thumb on PIC32 Maximum achievable trigger rate of DMA is System clock divided by 10, as i have read quite a few places each DMA transfer takes roughly  10 System Clock Cycles.

Experiment 1:

In this test I have setup PMP in slave mode, and we will using DMA to push data out of MCU over 8Bit Parallel Master port(PMP). PMP is also set to  Interrupt on each transfer  which will trigger DMA to copy one byte from a lookup table into PMDOUT register.
lookup table looks like this

uint8_t look_up[]=

This look up table will display like this on oscilloscope output :
RD is active low , which is set to active. and D0 to D7 shows lookup table on PMP 8bit Data output port.

DMA byte transfer rate ~100ns each transfer, DMA free triggered by PMP Transfer
Each Byte transfer trigger next DMA transfer of next byte, DMA also start automatically when when all bytes from table transferred, This test show Each byte take same amount of time of ~100ns.