This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem capturing video imaging using LCDK6748 from a Leopard Imaging camera

Other Parts Discussed in Thread: TMS320C6748, OMAPL138

Hello everyone.

I’m having problems for capturing video imaging with my LCDK6748. I’m using Leopard Imaging camera (RAW RGB, 10 bit, progressive, 1920x1080, 30fps). I’m trying to capture video using both channel 0 and channel 1 as a single channel.

First let me describe my steps:

  1. I plugged the Leopard camera on the LCDK6748.
  2. I modified the vpif_loopback example (C6748 StarterWare v1.20.03.03) and I configured the camera by I2C commands (the commands were provided by Omnivision).
  3. The signals generated by the camera were received by the DSP (VSYNC, HSYNC, CLKIN0, CLKIN1, and DIN[0:11]).
  4. The configuration was correct (well I guess so), actually the interrupt service routine for the VPIF was attended (when a HSYNC is recived) .

But when I checked the image buffer… were empty!

The code is the follow:

 

#define HORIZONTAL_PIXEL_COUNT     1920

#define VERTICAL_PIXEL_COUNT       1080

#define VBUF_SIZE       (HORIZONTAL_PIXEL_COUNT * VERTICAL_PIXEL_COUNT)

 

/* Buffer for the images */

unsigned short rawdata[VBUF_SIZE];

 

/* Global variables */

unsigned short verify=0;

unsigned int status;

 

/* Functions for CMOS sensor OV2715 */

void InitOV2715(void);

void TestPatternOV2715(void);

/* ISR for the VPIF */

static void VPIFIsr(void);

/* Initializes the I2C */

void InitI2c(void);

/* Initializes the VPIF interrupts */

void InitInt(void);

/* Initialize and configure the VPIF */

void InitVPIF(void);

 

int main(void)

{

            /* Setting the Master priority for the VPIF and LCD DMA controllers to highest level */

            HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI1) &= 0x00FFFFFF;

            HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI2) &= 0x0FFFFFFF;

            /* Set MAR bits and configure L1 cache */

            CacheEnableMAR((unsigned int)0xC0000000, (unsigned int)0x10000000);

            CacheEnable(L1PCFG_L1PMODE_32K | L1DCFG_L1DMODE_32K );

            //Initializes the VPIF interrupts

            InitInt();

            //Initializes the I2C

            InitI2c();

            /* Initialize the Leopard Camera (OV2715) */

            InitOV2715();

            /* Test Pattern for the Leopard Camera (OV2715) */

            TestPatternOV2715();

            /* Initialize and configure the VPIF */

            InitVPIF();

             while (1)

            {

             }

}

 

static void VPIFIsr(void)

{

    IntEventClear(SYS_INT_VPIF_INT);

    status = VPIFInterruptStatus(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);

     /* Initialize buffer addresses for the new frame*/

    VPIFCaptureFBConfig(SOC_VPIF_0_REGS,VPIF_CHANNEL_0, VPIF_TOP_FIELD,

                                           VPIF_LUMA,   (unsigned int) rawdata, 2*HORIZONTAL_PIXEL_COUNT);

     /* clear interrupt */

    VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);

    if(status==1)       //This part is just to check if this ISR is active

    {

            if(verify==65535) verify=0;

            else verify++;

    }

 }

 void InitVPIF(void)

{

            /* Power on VPIF */

            PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF,

                                              PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);

            /* Setup VPIF pinmux */

            VPIFPinMuxSetup();

            /* Disable interrupts */

            VPIFInterruptDisable(SOC_VPIF_0_REGS,

                                                 VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 |

                                                 VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);

            /* Disable capture ports */

            VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);

            VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);

             /* CH0, CH1 frame interrupt: Top field V-sync only */

            VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_TOP);

            VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_1,  VPIF_FRAME_INTERRUPT_TOP);

             /* 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);

            VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_RAW);

            VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_RAW, VPIF_CHANNEL_1, 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);

            VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_PROGRESSIVE);

            VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS, VPIF_REQSIZE_ONE_TWENTY_EIGHT);

            VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_HALT);

             /* Initialize buffer addresses for the frame*/ //FB Config

            VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,

                                                   VPIF_LUMA, (unsigned int)rawdata, 2*HORIZONTAL_PIXEL_COUNT);

             VPIFCaptureFieldframeModeSelect(SOC_VPIF_0_REGS,VPIF_FRAME_BASED);

             /* Enable capture */

            VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);

            VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);

             /* Enable interrupt FRAME0*/

            VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);

            VPIFInterruptEnableClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 | VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 |

                                                         VPIF_FRAMEINT_CH3|VPIF_ERROR_INT);

            VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);

}

 

The registers and their values after VPIF configurations are as:

C0CTRL               0x20001405

C1CTRL               0x00000405

INTEN                  0x00000001

INTSET                0x00000001

REQSIZE             0x00000080

C0TLUMA            0xC07E9000

C0IMGOFFSET   0x00000F00

C1TMULA            0x00000000

C1IMGOFFSER   0x00000000

 

Regarding with the value for the register C0TLUMA, well the address for the image bufferer (rawdata) is 0xC07E9000 (as demand the DSP datasheet). The rest of the registers are zeros.

Please, help me to capture video.

Thank you in advance.

 

By the way, an important problem with the LCDK6748 design: I had to remove the U27 (74LVC1G126DBV) because it was causing a problem with the Leopard Camera (regarding with the pixel clock).

  • Llich,


    Thanks for your post. I understand from your thread, you are working on your own board. It has TI TMS320C6748.
    Yes, It is possible for implementing of HD video on board with have TI TMS320C6748 using VPIF.
    You can use the available vpif interface in TMS320C6748.
    And also refer the section "5.27 Video Port Interface (VPIF)" in datasheet(TMS320C6748).

    The VPIF capture channel input data format is selectable based on the settings of the specific Channel
    Control Register (Channels 0-3).
    The VPIF Raw Video data-bus width is selectable based on the settings of the Channel 0 Control Register.

    TI provided the StarterWare examples for LCDK, It have video loopback project using vpif.

    C6748_StarterWare_x_xx_xx_xx\build\c674x\cgt_ccs\c6748\lcdkC6748\vpif_lcd_loopback
    C6748_StarterWare_x_xx_xx_xx\examples\lcdkC6748\vpif_lcd_loopback\vpif_lcd_loopback
    C6748_StarterWare_x_xx_xx_xx\platform\lcdkC6748\vpif.c
    Refer the product page, as mentioned the below link
    http://www.ti.com/tool/tmdxlcdk138
    You can download software packages for LCDKC6748.
    http://www.ti.com/tool/biossw-c6748

    The Video Port Interface (VPIF) allows the capture and display of digital video streams.

    Up to 2 Video Capture Channels (Channel 0 and Channel 1)

    •        Two 8-bit Standard-Definition (SD) Video with embedded timing codes (BT.656)
    •         Single 16-bit High-Definition (HD) Video with embedded timing codes (BT.1120)
    •         Single Raw Video (8-/10-/12-bit)

    Up to 2 Video Display Channels (Channel 2 and Channel 3)

    •       Two 8-bit SD Video Display with embedded timing codes (BT.656)
    •       Single 16-bit HD Video Display with embedded timing codes (BT.1120)

     Refer the section "Table 34-1. Supported Formats on VPIF" in TMS320C6748 TRM (spruh79)

  • Hi Pubesh

    Thank you very much for your answer. Regarding with the board, I’m using a LCDKC6748. And regarding with the documentation, yes, I already read the Datasheet and the Technical Reference for the TMS320C6748 and by the way I have used the StarterWare successfully until now.

    Look, I configured all the VPIF register according with the documentation (both technical reference and datasheet and the Starterware user manual). So, the configuration settings are for capture RAW images  - 10 bit, using CH0 and CH1 and for generate an interrupts each frame. Actually the register values for the commented configurations are:

    C0CTRL  = 0x20001405, C1CTRL = 0x00000405,  INTEN = 0x00000001, INTSET = 0x00000001, REQSIZE = 0x00000080, C0TLUMA = 0xC07E9000, C0IMGOFFSET = 0x00000F00, C1TMULA = 0x00000000, C1IMGOFFSER = 0x00000000

    I configured the above values using the StarterWare API.

    But my point is: I can’t capture images (the values from the address 0xC07E9000 are all zeros all the time).

    However, the CPU attends the ISR VPIF (I placed a counter variable and when the interrupt is attended the variable counts).

    So, my questions are very specific:

    1. Is my configuration correct for capture RAW images - 10 bit? I’m asking that because the technical data sheet avoids some details regarding with the RAW capture - 10 bit.
    2. Should I remove other components from the LCDKC6748? I’m asking that because previously I had to remove an IC (74LVC1G126DBV) from the LCDKC6748 otherwise the ISR VPIF never entered.

    Please, help me with this and thank you in advance.

  • Llich,

    Please kindly look for raw data capture in the TMS320C6748 TRM (spruh79).
    Table 34-3 describes the pin assignment on the VPIF for receiving video and capturing raw data.
    Shaded signals in Table 34-3 are synchronization signals that are necessary for capturing raw data.

    Table 34-3. Receive Pin Multiplexing Control

    Note that when capturing 10-bit or 12-bit video in the raw capture mode, the offset per line of data is
    doubled because of bit padding.

    The CAPMODE bit of the C0CTRL and C1CTRL control registers determines what data format will be
    captured by VPIF.
    The CCD/CMOS (Raw Data Capture) mode will look for video sync signals on the dedicated VPIF sync pins.
    When the CCD/CMOS mode is selected, channels 0 and 1 will work as a pair.
    Thus, both channels must be enabled before VPIF will capture receive data.
    Capture mode settings must be the same for both channels 0 and 1.

    And also go through the below sections in TRM,
    34.2.7 Raw Data Capture
    34.2.15.4 Raw Capture Mode

    For raw capture mode, the VPIF immediately starts to capture the data if you enable middle
    of frame.

    The storage mode have can configure frame-based or field-based (you can try this also)

    Note:
    VPIF_CAPTURE_RAW mode of the driver code is not done in the vpif.c file. Refer the below path and function mentioned.
    C6748_StarterWare_1_20_03_03\drivers\vpif.c

    VPIFCaptureModeConfig

    if(mode==VPIF_CAPTURE_RAW)
    {
    /* TBD */
    }

  • Hi Pubesh.

     

    Finally I could get images from my Leopard camera. But something is wrong because in some lines the image is shifted.

    I configured the camera as progressive, RAW mode, 1290x1080, 30 fps, but the image in the DSP is wrong.

    Actually I send the image captured with the DSP to a PC and I made a gray scale transform. The image result is bellow.

    Please help me with this final task because I don't know if the camera configuration or the VPIF configuration is wrong.

    Thanks in advance.

     

  • Llich,

    It looks good progress on your side, I think so the video configuration seems fine.
    I recommand you can add the "cache" function calls before "VPIFCaptureFBConfig" in your code.
    Kindly look the vpif driver calls for raw capture.

  • Hi Llich, 

    I would like to ask you for information. Which type of camera do you use ? You mentioned, that you use Leopard Imaging camera, but I am wondering which type of camera is it. Because we will use same board, I will appreciate if you provide this information. 

    Thank you, 

    Roman 

  • Hi Roman

     

    The camera is a LI-CAM-OV2715 (based on OV2715).

     

    Hi Pubesh.

     

    Finally I can get images. Just for further references I changed the camera frequency (from 80MHz to 40 MHz).

    By the way I have the code for that task in case that somebody could need it.

     

    Thank you very much for your asistance.

     

  • Hi Llich, 

    first of all, thank you for information. 

    I am really interested in the code for the task which you have already done. It will help me to start dealing with the  camera and LCDK board. Could you provide me this code as reference for further study, please. 

    Thank you.

    Roman 

  • Llich,

    Finally you have got the result.
    However this discussion of thread can helpful for future readers, If you verified this thread.
    You said that you want to share this software code, if need someone. You can share so that someone get for the best help.

  • Hi Pubesh

    You know? Now I have an issue when I try to debug the project with the XDS100v2 USB. An error message appears:

        Error connecting to the target:

        Connect to PRSC failed

    But I don’t know if it is a hardware problem or software problem or maybe something else. Look I just attached an LCD monitor but I’m not sure if that caused the problem.

    I ran the Test Connection in CCSv5 and everything seems to be good, actually I’m attaching the results.

    6825.TestConectionResults.txt
    [Start]
    
    Execute the command:
    
    %ccs_base%/common/uscif/dbgjtag -f %boarddatafile% -rv -o -F inform,logfile=yes -S pathlength -S integrity
    
    [Result]
    
    
    -----[Print the board config pathname(s)]------------------------------------
    
    C:\Users\ILICH~1.GUE\AppData\Local\.TI\693494126\
        0\0\BrdDat\testBoard.dat
    
    -----[Print the reset-command software log-file]-----------------------------
    
    This utility has selected a 100- or 510-class product.
    This utility will load the adapter 'jioserdesusb.dll'.
    The library build date was 'Oct  3 2012'.
    The library build time was '21:58:41'.
    The library package version is '5.0.872.0'.
    The library component version is '35.34.40.0'.
    The controller does not use a programmable FPGA.
    The controller has a version number of '4' (0x00000004).
    The controller has an insertion length of '0' (0x00000000).
    This utility will attempt to reset the controller.
    This utility has successfully reset the controller.
    
    -----[Print the reset-command hardware log-file]-----------------------------
    
    The scan-path will be reset by toggling the JTAG TRST signal.
    The controller is the FTDI FT2232 with USB interface.
    The link from controller to target is direct (without cable).
    The software is configured for FTDI FT2232 features.
    The controller cannot monitor the value on the EMU[0] pin.
    The controller cannot monitor the value on the EMU[1] pin.
    The controller cannot control the timing on output pins.
    The controller cannot control the timing on input pins.
    The scan-path link-delay has been set to exactly '0' (0x0000).
    
    -----[The log-file for the JTAG TCLK output generated from the PLL]----------
    
    There is no hardware for programming the JTAG TCLK frequency.
    
    -----[Measure the source and frequency of the final JTAG TCLKR input]--------
    
    There is no hardware for measuring the JTAG TCLK frequency.
    
    -----[Perform the standard path-length test on the JTAG IR and DR]-----------
    
    This path-length test uses blocks of 512 32-bit words.
    
    The test for the JTAG IR instruction path-length succeeded.
    The JTAG IR instruction path-length is 6 bits.
    
    The test for the JTAG DR bypass path-length succeeded.
    The JTAG DR bypass path-length is 1 bits.
    
    -----[Perform the Integrity scan-test on the JTAG IR]------------------------
    
    This test will use blocks of 512 32-bit words.
    This test will be applied just once.
    
    Do a test using 0xFFFFFFFF.
    Scan tests: 1, skipped: 0, failed: 0
    Do a test using 0x00000000.
    Scan tests: 2, skipped: 0, failed: 0
    Do a test using 0xFE03E0E2.
    Scan tests: 3, skipped: 0, failed: 0
    Do a test using 0x01FC1F1D.
    Scan tests: 4, skipped: 0, failed: 0
    Do a test using 0x5533CCAA.
    Scan tests: 5, skipped: 0, failed: 0
    Do a test using 0xAACC3355.
    Scan tests: 6, skipped: 0, failed: 0
    All of the values were scanned correctly.
    
    The JTAG IR Integrity scan-test has succeeded.
    
    -----[Perform the Integrity scan-test on the JTAG DR]------------------------
    
    This test will use blocks of 512 32-bit words.
    This test will be applied just once.
    
    Do a test using 0xFFFFFFFF.
    Scan tests: 1, skipped: 0, failed: 0
    Do a test using 0x00000000.
    Scan tests: 2, skipped: 0, failed: 0
    Do a test using 0xFE03E0E2.
    Scan tests: 3, skipped: 0, failed: 0
    Do a test using 0x01FC1F1D.
    Scan tests: 4, skipped: 0, failed: 0
    Do a test using 0x5533CCAA.
    Scan tests: 5, skipped: 0, failed: 0
    Do a test using 0xAACC3355.
    Scan tests: 6, skipped: 0, failed: 0
    All of the values were scanned correctly.
    
    The JTAG DR Integrity scan-test has succeeded.
    
    [End]

    There is another way to diagnostic my LCDKC6748 using the XDS100v2 USB emulator?

     

    And by the way, I’m attaching the code of my VPIF capture video, 

    8233.videoShare.c
    #include <stdio.h>
    #include <stdint.h>
    
    #include "psc.h"
    #include "vpif.h"
    #include "raster.h"
    #include "interrupt.h"
    #include "gpio.h"
    
    #include "lcdkC6748.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    #include "hw_syscfg0_C6748.h"
    #include "hw_types.h"
    
    #include "adv7343.h"
    #include "tvp5147.h"
    #include "cdce913.h"
    #include "codecif.h"
    #include "i2cgpio.h"
    
    #include "dspcache.h"
    
    #include "uart.h"
    #include "hw_uart.h"
    #include "uartStdio.h"
    #include "i2c.h"
    
    #define HORIZONTAL_PIXEL_COUNT 				1920
    #define VERTICAL_PIXEL_COUNT 				1080
    
    #define HORIZONTAL_DISPLAY	 				640
    #define VERTICAL_DISPLAY 					480
    
    
    #define VBUF_SIZE							(HORIZONTAL_PIXEL_COUNT * VERTICAL_PIXEL_COUNT)
    
    #define I2C_SLAVE_OV2715_WRITE				0x6C
    #define I2C_SLAVE_OV2715_READ				0x6D
    
    
    //Array for the data
    unsigned short rawdata0[VBUF_SIZE];
    
    
    //I2C Variables
    volatile unsigned int dataIdxM = 0, write;
    volatile unsigned int txCompFlagM = 1, rxCompFlagM=1;
    volatile unsigned int slaveDataM[3];
    
    // Camera Variables
    unsigned short OV2715ID;
    
    // Functions for CMOS sensor OV2715
    unsigned short GetIDOV2715(void);
    void TestPatternOV2715(void);
    void InitOV2715(void);
    
    //Devices ISR
    static void VPIFIsr(void);
    void I2CIsr(void);
    
    void EnviarDatosI2C(unsigned short SubAddr,  unsigned char Data);
    unsigned char RecibirDatosI2C(unsigned short SubAddr);
    static void Delay(volatile unsigned int delay);
    void InitI2c(void);
    void InitInt(void);
    void InitVPIF(void);
    
    //Test variables 
    unsigned short verify=0;
    
    
    int main(void)
    {
    
    		// Setting the Master priority for the VPIF and LCD DMA controllers to highest level
        	HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI1) &= 0x00FFFFFF;
        	HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI2) &= 0x0FFFFFFF;
        	// Set MAR bits and configure L1 cache (I'm not sure if this can help in further versions)
        	//CacheEnableMAR((unsigned int)0xC0000000, (unsigned int)0x10000000);
        	//CacheEnable(L1PCFG_L1PMODE_32K | L1DCFG_L1DMODE_32K );
        	//CacheEnable(L2CFG_L2MODE_256K );
    
        	// Initialize the Interrupts for the VPIF
        	InitInt();
    
        	// Initialize the I2C (and their interrupt)
        	InitI2c();
    
        	// Get ID from OV2715, must be 0x2710
        	OV2715ID=GetIDOV2715();
    
        	// Initialize the OV2715
        	InitOV2715();
    
        	// Test Pattern
        	//TestPatternOV2715();
    
        	// Initialize the VPIF
    		InitVPIF();
    
    		InitBuffers();
    
    	    vISP_TEST=RecibirDatosI2C(0x503D);
    
    
    	    while(1)
    	    {
    
    
    	    }
    
    }
    
    
    static void VPIFIsr(void)
    {
    	unsigned char status;
    
        IntEventClear(SYS_INT_VPIF_INT);
        status = VPIFInterruptStatus(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
        
    	//(I'm not sure if this can help in further versions)
    	//CacheInv((unsigned int) rawdata0,   2*VBUF_SIZE);
    
        if(verify==100)
        {
        	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
        	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
        	VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
        }
    
        // clear interrupt
         VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0|VPIF_FRAMEINT_CH1|VPIF_FRAMEINT_CH2|VPIF_FRAMEINT_CH3|VPIF_ERROR_INT);
    
         if(status==1)
         {
         	if(verify==65535) verify=0;
         	else verify++;
         }
    }
    
    
    
    void InitInt(void)
    {
    	// Initialize the DSP interrupt controller
    	IntDSPINTCInit();
    	// Register VPIF ISR to vector table
    	IntRegister(C674X_MASK_INT5, VPIFIsr);
    	// Map system interrupt to DSP maskable interrupt for VPIF
    	IntEventMap(C674X_MASK_INT5, SYS_INT_VPIF_INT);
    	// Enable DSP maskable interrupt for VPIF
    	IntEnable(C674X_MASK_INT5);
    
    	// Enable DSP interrupts
    	IntGlobalEnable();
    }
    
    
    void EnviarDatosI2C(unsigned short SubAddr,  unsigned char Data)
    {
        	slaveDataM[0] = (SubAddr>>8)&0xFF;
        	slaveDataM[1] = SubAddr&0xFF;
        	slaveDataM[2] = Data;
        	write=1;
        	txCompFlagM = 1;
        	dataIdxM = 0;
        	// Set I2C slave address for write
        	I2CMasterSlaveAddrSet(SOC_I2C_0_REGS, I2C_SLAVE_OV2715_WRITE>>1);
          	I2CSetDataCount(SOC_I2C_0_REGS, 3);
        	I2CMasterControl(SOC_I2C_0_REGS, I2C_CFG_MST_TX);
        	I2CMasterIntEnableEx(SOC_I2C_0_REGS, I2C_INT_TRANSMIT_READY);
        	I2CMasterStart(SOC_I2C_0_REGS);
         	// Wait till the data is sent
        	while(txCompFlagM);
    }
    
    unsigned char RecibirDatosI2C(unsigned short SubAddr)
    {
        	slaveDataM[0] = (SubAddr>>8)&0xFF;
        	slaveDataM[1] = SubAddr&0xFF;
        	write=0;
        	rxCompFlagM = 1;
        	dataIdxM = 0;
        	// Set I2C slave address for write
        	I2CMasterSlaveAddrSet(SOC_I2C_0_REGS, I2C_SLAVE_OV2715_WRITE>>1);
          	I2CSetDataCount(SOC_I2C_0_REGS, 2);
        	I2CMasterControl(SOC_I2C_0_REGS, I2C_CFG_MST_TX);
        	I2CMasterIntEnableEx(SOC_I2C_0_REGS, I2C_INT_TRANSMIT_READY);
        	I2CMasterStart(SOC_I2C_0_REGS);
        	while(rxCompFlagM);
    
        	rxCompFlagM = 1;
        	dataIdxM = 0;
        	I2CMasterSlaveAddrSet(SOC_I2C_0_REGS, I2C_SLAVE_OV2715_READ>>1);
          	I2CSetDataCount(SOC_I2C_0_REGS, 1);
        	I2CMasterControl(SOC_I2C_0_REGS, I2C_CFG_MST_RX);
        	I2CMasterIntEnableEx(SOC_I2C_0_REGS,I2C_INT_DATA_READY);
        	I2CMasterStart(SOC_I2C_0_REGS);
        	while(rxCompFlagM);
    
        	return (unsigned char) slaveDataM[0];
    }
    
    void I2CIsr(void)
    {
        	unsigned int intCode = 0;
        	// Get interrupt vector code
        	intCode = I2CInterruptVectorGet(SOC_I2C_0_REGS);
        	// Clear interrupt status
        	IntEventClear(SYS_INT_I2C0_INT);
        	if (intCode == I2C_INTCODE_TX_READY)
        	{
        		I2CMasterDataPut(SOC_I2C_0_REGS, slaveDataM[dataIdxM]);
           		dataIdxM++;
           		if (dataIdxM==2 && write==0)
           		{
            	 	I2CMasterIntDisableEx(SOC_I2C_0_REGS,I2C_INT_TRANSMIT_READY);
            	 	I2CMasterIntEnableEx(SOC_I2C_0_REGS,I2C_INT_STOP_CONDITION);
            	 	I2CMasterStop(SOC_I2C_0_REGS);
           		}
           		else if (dataIdxM==3 && write==1)
           		{
           			I2CMasterIntDisableEx(SOC_I2C_0_REGS, I2C_INT_TRANSMIT_READY);
           			I2CMasterIntEnableEx(SOC_I2C_0_REGS,I2C_INT_STOP_CONDITION);
           			I2CMasterStop(SOC_I2C_0_REGS);
           		}
        	}
        	if(intCode == I2C_INTCODE_RX_READY)
        	{
        		slaveDataM[dataIdxM] = I2CMasterDataGet(SOC_I2C_0_REGS);
        		I2CMasterIntDisableEx(SOC_I2C_0_REGS,I2C_INT_DATA_READY);
        		I2CMasterIntEnableEx(SOC_I2C_0_REGS,I2C_INT_STOP_CONDITION);
        		I2CMasterStop(SOC_I2C_0_REGS);
        	}
        	if (intCode == I2C_INTCODE_STOP)
        	{
        		// Disable all interrupts
          		I2CMasterIntDisableEx(SOC_I2C_0_REGS,I2C_INT_TRANSMIT_READY|I2C_INT_DATA_READY|I2C_INT_STOP_CONDITION);
          		if (write==1)txCompFlagM = 0;
          		else if (write==0) rxCompFlagM = 0;
         	}
    }
    
    unsigned short GetIDOV2715(void)
    {
    	unsigned char PIDH, PIDL;
    	PIDH = RecibirDatosI2C(CHIP_VERSION_H);	//After reset value 0x27
    	PIDL = RecibirDatosI2C(CHIP_VERSION_L);	//After reset value 0x10
    	return (PIDH<<8) | (PIDL);
    }
    
    void InitI2c(void)
    {
    	// Initialize I2C for program CMOS sensor OV2715
    	I2CPinMuxSetup(0);
    	// Put I2C in reset/disabled state
    	I2CMasterDisable(SOC_I2C_0_REGS);
    	// Configure I2c bus speed to 50khz
    	I2CMasterInitExpClk(SOC_I2C_0_REGS, 24000000, 8000000, 50000);
    	// Enable I2C
    	I2CMasterEnable(SOC_I2C_0_REGS);
    	// Register I2C ISR to vector table
    	IntRegister(C674X_MASK_INT4, I2CIsr);
    	// Map system interrupt to DSP maskable interrupt for I2C
    	IntEventMap(C674X_MASK_INT4, SYS_INT_I2C0_INT);
    	// Enable DSP maskable interrupt for I2C
    	IntEnable(C674X_MASK_INT4);
    }
    
    void InitOV2715(void)
    {
    	//Sorry I not able to release this area because it is confidential (we signed an NDA with Omnivision).
    	//But you can try to ask the initialization from Omnivision.
    	//Remember, take in account the maximum pixel clock allowed for VPIF, for example
    	//for the LCDK6748 I tested with good results when the pixel clock frequency was sated up to 
    	//40MHz (I modified the PLL settings of my camera to do that)	
    
    }
    
    static void Delay(volatile unsigned int delay)
    {
    while(delay--);
    }
    
    
    
    void TestPatternOV2715 (void)
    {
    	// ISP Control; color bar rolling disabled, Color bar pattern selected: Color bar pattern, Color bar enable
    	EnviarDatosI2C(ISP_TEST,0xA0);
    }
    
    
    void InitVPIF(void)
    {
    	// Power on VPIF
    	PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
    	// Setup VPIF pinmux
    	VPIFPinMuxSetup();
    
    	// Disable interrupts
    	VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
      	// Disable capture ports
    	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    
    	// CH0, CH1 frame interrupt: Top field V-sync only
    	VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_TOP);
    	VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_FRAME_INTERRUPT_TOP);
    
    	// RAW mode
    	VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_RAW);
    	VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_RAW);
    	VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_RAW, VPIF_CHANNEL_0, 0, (VPIFVbufParam*) 0);
    	VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_RAW, VPIF_CHANNEL_1, 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);
    	VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_PROGRESSIVE);
    
    	// Size of the REQSIZE
    	VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS,VPIF_REQSIZE_TWO_FIFTY_SIX);
    
    	VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_HALT);
    
    	//I'm not sure if this is useful
    	CacheInv(rawdata0,2*VBUF_SIZE);
    
    	// Initialize buffer addresses for the frame
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS,VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)rawdata0, 2*HORIZONTAL_PIXEL_COUNT);	
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS,VPIF_CHANNEL_1, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)rawdata0, 2*HORIZONTAL_PIXEL_COUNT);	
    
    	// Type of the memory organization
    	VPIFCaptureFieldframeModeSelect(SOC_VPIF_0_REGS,VPIF_FRAME_BASED);
    
    	// Enable capture
    	VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    	VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    
    	// Disable the Ancillary areas
    	VPIFCaptureVancDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    	VPIFCaptureVancDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    	VPIFCaptureHancDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    	VPIFCaptureHancDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    
    	// No YC muxed mode
    	VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_YC_NONMUXED);
    	VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_YC_NONMUXED);
    
    	// Enable interrupt FRAME0
    	VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    	VPIFInterruptEnableClear(SOC_VPIF_0_REGS,VPIF_FRAMEINT_CH0|VPIF_FRAMEINT_CH1|VPIF_FRAMEINT_CH2|VPIF_FRAMEINT_CH3|VPIF_ERROR_INT); //Clear all interrupts
    	VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    
    	// Change the VSYNC polarization
    	VPIFCaptureRawVvinvSet(SOC_VPIF_0_REGS,VPIF_RAW_VVALID_INVERT);
    }
    , but it is not complete, for now until I solve the problem described above. But this code is going to help so much. To test if your application works you have to perform other task: First, you have to get the initialization commands for your camera (the commands inside of the InitOV2715 function) because I’m not allowed to distribute this information, we signed a NDA with Omnivision, but you can try to ask them for it. The second one is to save the rawdata0 using the debug session in CCSv5 and open it with MATLAB or Visual C# to validate the image (I did so).

  • Llich,

    I have seen the TestConnectionResult.txt, It seems no issue with JTAG connection.
    I would recommend you, create new thread for CCS connectivity issue.
    Because this thread was verified for your earlier query.
    You can get the best help from CCS forum for target connectivity issue.

  • Hi Illich Guerrero,

                  I'm trying to interface Omnivision OV2640 to DSP core of OMAP processor, the processor uses vpif port for capturing the raw data, I'm following the guide lines given in LogicPD bsl files , but i'm unable to capture the image.

                   If possible can you kindly mail the code or guide lines that you followed in order to get the image/frame from the sensor and display display on the PC.

           Also can you specify hardware interface settings used.

  • Hi Vaishak

    I can help you, finally my application works very well, but not now, i'm very busy right now, maybe the next week.

    But your first step is getting the initial commands for the sensor OV2640, if you have them cool, otherwise you need them (contact omnivision for that).

    Other thing check the frecuency for the pixels, because this is a BIG issue.

    As son as posible i seend you the VPIF initialization.

    Best regards

  • Hi Ilich,

             Sorry for troubling you again , I'm attaching the the C file done by me after going through several posts on this forum regarding VPIF raw  data capture. Can you kindly check it and kindly give the guidelines that you had used in displaying the captured image in memory browser window of Code composer studio.

    I'm using board support libraries of logic pd and staterware of OMAPL138

    All raw_h_valid and raw_v_valid signals are appearing in Sync with the timing diagram provided by VPIF of Omapl138 an d clock on CLK_VIN0/1 is 75Mhz.

    I'm trying to capture raw image in 720p format .

    I'm trying to store the data in DDR2 section i.e. 0xc0000000 to 0xcfffffff  .

    If i check through the memory browser then it shows nothing, but if i try printing the data from section used then it keeps on repeating 4 32 bit words repetitively irrespective the length printed. 

    0825.main.c
    //-----------------------------------------------------------------------------
    // \file    main.c
    // \brief   implementation of main() to test bsl drivers.
    //
    //-----------------------------------------------------------------------------
    #include "stdio.h"
    #include "types.h"
    #include "evmomapl138.h"
    #include "evmomapl138_timer.h"
    #include "evmomapl138_gpio.h"
    #include "evmomapl138_i2c.h"
    #include "omapl138_OV2643.h"
    #include "evmomapl138_mmcsd.h"
    #include "OV2643_reg_setup.h"
    
    //-----------------------------------------------------------------------------
    // Private Defines and Macros
    //-----------------------------------------------------------------------------
    // uncomment this define if running without gel initialization.
    // #define NO_GEL    (1)
    
    #define Horizontal_pixel_cnt 1280
    #define Vertical_pixel_cnt 720
    
    #define Video_Buf Horizontal_pixel_cnt*Vertical_pixel_cnt
    
    #ifdef _TMS320C6X
    #include "dspcache.h"
    #else
    #include "cp15.h"
    #ifdef gcc
    #define restrict
    #endif
    #endif
    //-----------------------------------------------------------------------------
    // Static Variable Declarations
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Private Function Prototypes
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Public Function Definitions
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // \brief   entry point for bsl test code.
    //
    // \param   none.
    //
    // \return  none.
    //-----------------------------------------------------------------------------
    
    int main(void)
    {
       unsigned int results = 0;
       unsigned int rtn;
    
      // PREVIEW_PARAM _param;
    #if NO_GEL
       EVMOMAPL138_init();
       EVMOMAPL138_initRAM();
    #endif
    
       // init the us timer and i2c for all to use.
       USTIMER_init();
       I2C_init(I2C0,I2C_CLK_400K);
       rtn = OV2643_init();
       OV2643_soft_reset();
    
    
       if (rtn != ERR_NO_ERROR)
             {
                printf("error initializing OV2643!\r\n");
                return (rtn);
             }
    
    
    #ifndef _TMS320C6X
        unsigned int index;
    #endif
    
        /* Setting the Master priority for the VPIF and LCD DMA controllers to highest level*/
        HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI1) &= 0x00FFFFFF;
        HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_MSTPRI2) &= 0x0FFFFFFF;
    
    #ifdef _TMS320C6X
         /*Set MAR bits and configure L1 cache*/
        CacheEnableMAR((unsigned int)0xC0000000, (unsigned int)0x10000000);
        CacheEnable(L1PCFG_L1PMODE_32K | L1DCFG_L1DMODE_32K );
        printf("Cache enabled \r\n");
    #else
         /*Sets up 'Level 1" page table entries.
         * The page table entry consists of the base address of the page
         * and the attributes for the page. The following operation is to
         * setup one-to-one mapping page table for DDR memory range and set
         * the attributes for the same. The DDR memory range is from 0xC0000000
         * to 0xCFFFFFFF. Thus the base of the page table ranges from 0xC00 to
         * 0xCFF. Cache(C bit) and Write Buffer(B bit) are enabled  only for
         * those page table entries which maps to DDR RAM and internal RAM.
         * All the pages in the DDR range are provided with R/W permissions*/
        for(index = 0; index < (4*1024); index++)
        {
             if((index >= 0xC00 && index < 0xD00)|| (index == 0x800))
             {
                  pageTable[index] = (index << 20) | 0x00000C1E;
             }
             else
             {
                  pageTable[index] = (index << 20) | 0x00000C12;
             }
        }
    
         /*Configures translation table base register
         * with pagetable base address.*/
        CP15TtbSet((unsigned int )pageTable);
    
         /*Enables MMU*/
        CP15MMUEnable();
    
    /*     Enable Instruction Cache*/
        CP15ICacheEnable();
    
         /*Enable Data Cache*/
        CP15DCacheEnable();
    #endif
    
        ov2643_cam_table_write(OV2643_REGS_720p);
        VPIF_raw_capture_init();
    
    
       if (rtn != ERR_NO_ERROR)
          {
             printf("error initializing OV2643!\r\n");
             return (rtn);
          }
    
       // TEST IMAGE_SENSOR
       //------------------
       while(1);
    
       if (results != ERR_NO_ERROR)
          printf("\r\n\r\n********** OMAP-L138 TEST FAILED **********\r\n\r\n");
       else
          printf("\r\n\r\n********** OMAP-L138 TEST PASSED **********\r\n\r\n");
    }
    

    0871.omapl138_OV2643.c
    #include "omapl138_OV2643.h"
    #define HW_PSC_VPIF 9
    
    //-----------------------------------------------------------------------------
    // Private Defines and Macros
    //-----------------------------------------------------------------------------
    
    // i2c defines.
    
    //-----------------------------------------------------------------------------
    // Private Function Prototypes
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // Public Function Definitions
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    // .
    //-----------------------------------------------------------------------------
    
    volatile unsigned int   captured=0, changed=0, updated=3, processed=1;
    /* page tables start must be aligned in 16K boundary */
    #ifdef __TMS470__
    #pragma DATA_ALIGN(pageTable, 16384);
    static volatile unsigned int pageTable[4*1024];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment=16384
    static volatile unsigned int pageTable[4*1024];
    #elif _TMS320C6X
    #else
    static volatile unsigned int pageTable[4*1024] __attribute__((aligned(16*1024)));
    #endif
    //static uint16_t slave_i2c_addr = 0;
    unsigned short picBuf1[VBUF_SIZE*2];
    #pragma DATA_SECTION(picBuf1,"PICTURE");
    
    unsigned short picBuf2[VBUF_SIZE*2];
    #pragma DATA_SECTION(picBuf2,"PICTURE");
    
    unsigned short picBuf3[VBUF_SIZE*2];
    #pragma DATA_SECTION(picBuf3,"PICTURE");
    unsigned short *picBuffer[3];
    unsigned int frame=0;
    unsigned int getPIC=0;
    unsigned int curPicBuff;
    unsigned int prevfram;
    
    void VPIFIsr(void)
    {
    	unsigned int status;
    	uint16_t i,curr;
    #ifdef _TMS320C6X
        IntEventClear(SYS_INT_VPIF_INT);
    #else
        IntSystemStatusClear(SYS_INT_VPIF);
    #endif
    
    		status = VPIFInterruptStatus(SOC_VPIF_0_REGS, VPIF_ERROR_INT | VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH0);
    
    		/* Initialize buffer addresses for a new frame  */
    		if (getPIC&&(VPIF_FRAMEINT_CH0 & status)){
    			curr = getCurPIC();
    			/*printf("Current read frame %d\r\n",curr);
    			for(i=0;i < 100; i++)
    			printf("%d 0x%x,\r\n",i,picBuf1[curPicBuff + i]);*/
    			frame++;
    			curPicBuff=frame%3;  //marks the current captured frame
    			printf("Current read frame %d\r\n",curPicBuff);
    			if (frame==99999) frame=0;
    
    			switch(curPicBuff)
    			{
    			case 0:
    				printf("1\r\n");
    				VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    					VPIF_LUMA, (unsigned int) picBuf1, VBUF_SIZE*2);
    				VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
    				USTIMER_delay(2 * DELAY_HALF_SEC);
    				if(picBuf1[0]!= NULL)printf("DATA1\r\n");
    			getPIC=0;
    			break;
    			case 1:
    				printf("2\r\n");VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    					VPIF_LUMA, (unsigned int) picBuf2, VBUF_SIZE*2);
    				VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
    				USTIMER_delay(2 * DELAY_HALF_SEC);
    				if(picBuf2[0]!= NULL)printf("DATA2\r\n");
    			getPIC=0;
    			break;
    			case 2:
    				printf("3\r\n");
    				VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    								VPIF_LUMA, (unsigned int) picBuf3, VBUF_SIZE*2);
    				VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
    				USTIMER_delay(2 * DELAY_HALF_SEC);
    				if(curPicBuff == 2)
    				VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
    				if(*picBuf3!= NULL){printf("DATA3\r\n");
    				for(i=0 ; i < 1843200; i++)
    					printf("%d %d\r\n",i,picBuf3[0+i]);}
    						getPIC=0;
    						break;
    
    			default:
    				printf("Improper frame\r\n");
    			}
    
    			if(curPicBuff != 2)
    				VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 );
    
    		}
    
    		/* clear interrupt */
    		VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    
    		// if error interrupt occurs, report error
    		if ((status & VPIF_ERROR_INT)) {
    			printf(" Channel 0 & 1 error");
    		}
    
    		swapBuff();
    }
    
    /*
    ** Configures arm/dsp interrupt controller to generate frame interrupt
    */
    void SetupIntc(void)
    {
        /* Setup DSP or ARM interrupt controller */
    
    #ifdef _TMS320C6X
        /* Initialize the DSP interrupt controller */
        IntDSPINTCInit();
    
        /* Register ISR to vector table */
        IntRegister_DSP(C674X_MASK_INT5, VPIFIsr);
    
        /* Map system interrupt to DSP maskable interrupt */
        IntEventMap(C674X_MASK_INT5, SYS_INT_VPIF_INT);
    
        /* Enable DSP maskable interrupt */
        IntEnable_DSP(C674X_MASK_INT5);
    
        /* Register LCD ISR to vector table */
        IntRegister_DSP(C674X_MASK_INT6, LCDIsr);
    
        /* Map system interrupt to DSP maskable interrupt for LCD */
        IntEventMap(C674X_MASK_INT6, SYS_INT_LCDC_INT);
    
        /* Enable DSP maskable interrupt for LCD */
        IntEnable_DSP(C674X_MASK_INT6);
    
        /* Enable DSP interrupts */
        IntGlobalEnable_DSP();
    #else
        /* Initialize the ARM Interrupt Controller.
        IntAINTCInit();
    
         Register the ISR in the Interrupt Vector Table.
        IntRegister(SYS_INT_VPIF, VPIFIsr);
    
         Set the channel number 2 of AINTC for LCD system interrupt.
        IntChannelSet(SYS_INT_VPIF, 2);
    
         Enable the System Interrupts for AINTC.
        IntSystemEnable(SYS_INT_VPIF);
    
         Enable IRQ in CPSR.
        IntMasterIRQEnable();
    
         Enable the interrupts in GER of AINTC.
        IntGlobalEnable();
    
         Enable the interrupts in HIER of AINTC.
        IntIRQEnable();*/
    #endif
    
        printf("Set up interrupt controller \r\n");
    }
    
    
    void swapBuff(){
    	getPIC=1;
    }
    
    unsigned int getCurPIC(){
    	return curPicBuff;
    }
    
    unsigned int prevframe(){
    
    	if(curPicBuff > 0)
    	{
    		prevfram = --curPicBuff;
    	}
    return prevfram;
    }
    void VPIF_raw_capture_init()
    {
    	picBuffer[0] = picBuf1;
    	picBuffer[1] = picBuf2;
    	picBuffer[2] = picBuf3;
    	SetupIntc();
    		 printf("VPIF Init \r\n");
    
    	/* Power on VPIF */
    	PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF, PSC_POWERDOMAIN_ALWAYS_ON,PSC_MDCTL_NEXT_ENABLE);
    
    	/* Setup VPIF pinmux */
    	configReceivePinMux();
    
    
    	//SetUpVPIFRx();
    
    		// Disable interrupts
    		VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 |VPIF_FRAMEINT_CH1 | VPIF_FRAMEINT_CH2 | VPIF_FRAMEINT_CH3 | VPIF_ERROR_INT);
    		VPIFCaptureHancDisable(SOC_VPIF_0_REGS,VPIF_CHANNEL_0);
    		VPIFCaptureHancDisable(SOC_VPIF_0_REGS,VPIF_CHANNEL_1);
    		VPIFCaptureVancDisable(SOC_VPIF_0_REGS,VPIF_CHANNEL_0);
    		VPIFCaptureVancDisable(SOC_VPIF_0_REGS,VPIF_CHANNEL_1);
    	  	// Disable capture ports
    		VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    		VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    
    		// CH0, CH1 frame interrupt: Top field V-sync only
    		VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_TOP);
    		//VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_FRAME_INTERRUPT_TOP_BOTTOM);
    
    		VPIFCaptureRawIntlineConfig(SOC_VPIF_0_REGS,720);
    
    		/*VPIFCaptureClkedgeModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_0,VPIF_CLKEDGE_RISING);
    		VPIFCaptureClkedgeModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_1,VPIF_CLKEDGE_RISING);*/
    
    		// RAW mode
    		VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_RAW);
    		VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_RAW);
    
    		VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_CAPTURE_RAW, VPIF_CHANNEL_0, 0, (VPIFVbufParam*) 0);
    		VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_CAPTURE_RAW, VPIF_CHANNEL_1, 0, (VPIFVbufParam*) 0);
    
    		// 8 bit data
    		VPIFCaptureRawDatawidthConfig(SOC_VPIF_0_REGS, VPIF_RAW_EIGHT_BPS);
    
    		// Progressive capture
    		VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_PROGRESSIVE);
    		VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_PROGRESSIVE);
    
    		// Size of the REQSIZE
    		VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS,VPIF_REQSIZE_TWO_FIFTY_SIX);
    
    		VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_HALT);
    
    
    
    		// Initialize buffer addresses for the frame
    		VPIFCaptureFBConfig(SOC_VPIF_0_REGS,VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)picBuf1, 2*VBUF_SIZE);
    		VPIFCaptureFBConfig(SOC_VPIF_0_REGS,VPIF_CHANNEL_1, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int)picBuf1, 2*VBUF_SIZE);
    
    		// Type of the memory organization
    		VPIFCaptureFieldframeModeSelect(SOC_VPIF_0_REGS,VPIF_FRAME_BASED);
    
    		// No YC muxed mode
    		VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_YC_NONMUXED);
    		VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_YC_NONMUXED);
    
    		// Enable interrupt FRAME0
    				VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 | VPIF_FRAMEINT_CH1 );
    				VPIFInterruptEnableClear(SOC_VPIF_0_REGS,VPIF_FRAMEINT_CH0|VPIF_FRAMEINT_CH1|VPIF_FRAMEINT_CH2|VPIF_FRAMEINT_CH3|VPIF_ERROR_INT); //Clear all interrupts
    				VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0 | VPIF_FRAMEINT_CH1);
    
    		// Enable capture
    		VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    		VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    
    
    }
    
    
    /*
     * Initialize capture
    */
    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);
    
    	// config dma request size and emulation control.
    	VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS, VPIF_REQSIZE_TWO_FIFTY_SIX);
    	VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_FREE);
    
    	// Set Clock to FALLING EDGE (calling RISING because TI messed things up and mixed the parameters)
    	//VPIFCaptureClkedgeModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_0,VPIF_CLKEDGE_RISING);
    	//VPIFCaptureClkedgeModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_1,VPIF_CLKEDGE_RISING);
    
    	//HVALID and VVALID inversion
    
    	VPIFCaptureRawVvinvSet(SOC_VPIF_0_REGS,VPIF_RAW_VVALID_INVERT);
    
    	// Interrupt every 720 lines
    	VPIFCaptureRawIntlineConfig(SOC_VPIF_0_REGS,720);
    
    	/*///////////Horizontal ancillary enable
    	VPIFCaptureHancEnable(SOC_VPIF_0_REGS,VPIF_CHANNEL_0);
    	VPIFCaptureHancEnable(SOC_VPIF_0_REGS,VPIF_CHANNEL_1);
    	////////Vertical ancillary enable
    	VPIFCaptureVancEnable(SOC_VPIF_0_REGS,VPIF_CHANNEL_0);
    	VPIFCaptureVancEnable(SOC_VPIF_0_REGS,VPIF_CHANNEL_1);*/
    
    
    	////// Y/C MUX mode
    
    	VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_0,VPIF_YC_NONMUXED);
    	VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS,VPIF_CHANNEL_1,VPIF_YC_NONMUXED);
    
    
    	// Interrupt after capturing the bottom field of every frame
    	VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_TOP);
    	VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_FRAME_INTERRUPT_TOP);
    
    	// RAW mode
    	VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_RAW);
    	VPIFCaptureCapmodeModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_RAW);
    
    	VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_CAPTURE_RAW, VPIF_CHANNEL_0, 0, (VPIFVbufParam*) 0);
    	VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_CAPTURE_RAW, VPIF_CHANNEL_1, 0, (VPIFVbufParam*) 0);
    
    	// 8 bits bit data
    	VPIFCaptureRawDatawidthConfig(SOC_VPIF_0_REGS,VPIF_RAW_EIGHT_BPS);
    
    	// Progressive capture
    	VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_CAPTURE_PROGRESSIVE);
    	VPIFCaptureIntrprogModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_1, VPIF_CAPTURE_PROGRESSIVE);
    
    	// Change to Frame based for Progressive Scan
    	VPIFCaptureFieldframeModeSelect(SOC_VPIF_0_REGS,VPIF_FRAME_BASED);
    
    	printf("VPIF RX\r\n");
    }
    
    void configReceivePinMux(void)
    {
       EVMOMAPL138_pinmuxConfig(PINMUX_VPIF_RX_REG_0, PINMUX_VPIF_RX_MASK_0, PINMUX_VPIF_RX_VAL_0);
       EVMOMAPL138_pinmuxConfig(PINMUX_VPIF_RX_REG_1, PINMUX_VPIF_RX_MASK_1, PINMUX_VPIF_RX_VAL_1);
       EVMOMAPL138_pinmuxConfig(PINMUX_VPIF_RX_REG_2, PINMUX_VPIF_RX_MASK_2, PINMUX_VPIF_RX_VAL_2);
    }
    
    
    

  • hi  

    i am using OMAP L138 LCDK for my project on object detection i want to know which camera exactly u used for above programming pls tell me the part no of the camera and how did u interface it with the kit and the camera  thau u hv used will be suitable with my kit or not . pls reply i really need help regarding the camera issues for my project..

    thank you

  • Mr. :

    Now I am also using the TMS320C6748 LCDK , and I am trying to connect the CMOS sensor , the OV2715 can meet my need .

    I have already connected a camera to the J9 , and connected the VGA LCD panel to the J8 , and the image can be displayed on the LCD panel . but the system does not work well .

    So , can you send me your source code for the OV2715 initialization and image capturing ? 

    Thanks !

    Good Lcuk !

    Zhangbin . 

    my email :alex_zhang68@126.com

  • Hi Ilich,

    I am working on communicating C6748 and OV2715. I have the initialization file from OmniVision. But the content is : "6c 3103 93  6c 3008 82 6c 3017 7f ..." . How to integrate them in the C code? And the initialization file also is not the right C format. I am new in the image DSP area. Thanks in advance.

  • What is function  this "InitBuffers();"?

    Can I disable InitBuffers();?

  • Hi,

    Use:  configureVpif0(EvmInit_VpifChannel_BOTHCAPCH, FALSE);

    The 2 capture ports work in a pair.

    Had the same issue with the LCDK since the drivers were originally made for Logic PD EVM.

    Avi.