Hello,
I would like to use Aptina MT9M034 color sensor for capturing video and still images.
- Resolution: 1280 x 960pixels
- Parallel 12 bit progressive output, bayern pattern
- If buffers are setup correctly
- If VPIF is configured correctly in SetUpVPIFRx
/*
 *  Created on: 29.11.2012
 *      Author: Andres Vahter
 */
#include "psc.h"
#include "vpif.h"
#include "interrupt.h"
#include "evmC6748.h"
#include "soc_C6748.h"
#include "hw_psc_C6748.h"
#include "vpiftransfer.h"
#define HORIZONTAL_PIXEL_COUNT 	1280
#define VERTICAL_PIXEL_COUNT 	960
#define VBUF_SIZE	(HORIZONTAL_PIXEL_COUNT * VERTICAL_PIXEL_COUNT)
#define VBUF_ALIGN  (8)
unsigned char chromaTop[VBUF_SIZE]__attribute__((aligned(VBUF_ALIGN)));
unsigned char chromaBottom[VBUF_SIZE]__attribute__((aligned(VBUF_ALIGN)));
unsigned char lumaTop[VBUF_SIZE]__attribute__((aligned(VBUF_ALIGN)));
unsigned char lumaBottom[VBUF_SIZE]__attribute__((aligned(VBUF_ALIGN)));
void VPIF_init(void) {
	// Power on VPIF
	PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
	// Initializing DSP INTC
	SetupIntc();
    // Setup VPIF pinmux & Initialize VPIF
    VPIFPinMuxSetup();
    SetUpVPIFRx();
    VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS, VPIF_REQSIZE_ONE_TWENTY_EIGHT);
    VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_FREE);
    // Initialize buffer address for 1st frame
    VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)&lumaTop[0], HORIZONTAL_PIXEL_COUNT);
    VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_CHROMA, (unsigned int)&chromaTop[0], HORIZONTAL_PIXEL_COUNT);
    VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_LUMA, (unsigned int)&lumaBottom[0], HORIZONTAL_PIXEL_COUNT);
    VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_CHROMA, (unsigned int)&chromaBottom[0], HORIZONTAL_PIXEL_COUNT);
}
void VPIF_enable_capture(void) {
    // Enable capture
    VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
}
// Initialize capture
static void SetUpVPIFRx(void) {
    // Disable interrupts
    VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH1);
    VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    // Disable capture ports
    VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    // Interrupt after capturing the bottom field of every frame
    VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_BOTTOM);
    // RAW mode
    VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_RAW);
    VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_RAW, VPIF_CHANNEL_0, 0, (VPIFVbufParam*) 0);
    // 12 bit data
    VPIFCaptureRawDatawidthConfig(SOC_VPIF_0_REGS, VPIF_RAW_TWELVE_BPS);
    // Progressive capture
    VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_PROGRESSIVE);
}
// Configures DSP interrupt controller to generate frame interrupt
static void SetupIntc(void) {
    // Initialize the DSP interrupt controller
    IntDSPINTCInit();
    // Register ISR to vector table
    IntRegister(C674X_MASK_INT5, VPIFIsr);
    // Map system interrupt to DSP maskable interrupt
    IntEventMap(C674X_MASK_INT5, SYS_INT_VPIF_INT);
    // Enable DSP maskable interrupt
    IntEnable(C674X_MASK_INT5);
    // Enable DSP interrupts
    IntGlobalEnable();
}
// Interrupt service routine.
static void VPIFIsr(void) {
    unsigned int status;
    IntEventClear(SYS_INT_VPIF_INT);
    status = VPIFInterruptStatus(SOC_VPIF_0_REGS, VPIF_ERROR_INT | VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH0);
	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)&lumaTop[0], HORIZONTAL_PIXEL_COUNT);
	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_CHROMA, (unsigned int)&chromaTop[0], HORIZONTAL_PIXEL_COUNT);
	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_LUMA, (unsigned int)&lumaBottom[0], HORIZONTAL_PIXEL_COUNT);
	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_CHROMA, (unsigned int)&chromaBottom[0], HORIZONTAL_PIXEL_COUNT);
    // clear interrupt
    VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    // if error interrupt occurs, report error
    if ((status & VPIF_ERROR_INT)) {
        // what to do?
    }
}
 
				 
		 
					 
                           
				 
				