CMOS DSP Interface
CMOS DSP Interface
ABSTRACT
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 CMOS Digital Image Sensor Overview ........................................................................................ 3
2.1 CMOS Sensor Signal Descriptions ......................................................................................... 3
2.2 CMOS Sensor Register Descriptions ...................................................................................... 4
2.2.1 Row and Column Size ................................................................................................. 5
2.2.2 Horizontal and Vertical Blanking .................................................................................. 5
2.2.3 Shutter Width ............................................................................................................... 5
2.2.4 Pixel Clock Control ...................................................................................................... 5
2.2.5 Read Mode 1 ............................................................................................................... 5
2.2.6 Read Mode 2 ............................................................................................................... 5
2.3 Reading and Writing the CMOS Sensor Registers.................................................................. 6
2.3.1 Sensor Output Data Format ........................................................................................ 7
3 DM642 Video Port Overview ......................................................................................................... 7
3.1 Video Capture Port Signal Descriptions .................................................................................. 8
3.2 Raw Capture Mode ................................................................................................................. 8
3.3 Frame Synchronization ........................................................................................................... 9
4 Sensor Interface to the to DM642 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1 Hardware Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 Software Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2.1 Raw Capture Mode Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2.2 Raw Display Mode Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2.3 Sensor EDC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Capture and Display Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1
SPRAA52A
Appendix A Sensor Daughter Card Schematics for the DM642 EVM .......................................... 20
List of Figures
Figure 1. Non-Continuous and Continuous LINE_VALID Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 2. I2C Write to Column Size Register (0x04) with the Value 0x027F . . . . . . . . . . . . . . . . . . . . . . 6
Figure 3. I2C Read from Column Size Register (0x04). 0x027F Returned . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 4. Bayer Color Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 5. VCxSTRT1 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 6. Initializing VCVBLNKP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 7. Sensor Interface to the DM642 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 8. Proper LINE_VALID Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 9. Capture Configuration Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 10. Raw Capture Mode Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 11. SAA7105 Configuration for SVGA Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 12. RGB565 Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 13. Bayer Pattern (4x4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 14. FVID Object Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
List of Tables
Table 1 Sensor Signal Descriptions ................................................................................................ 4
Table 2 I2C Sensor Addresses ....................................................................................................... 6
Table 3 Video Capture Port Signal Descriptions (Raw Capture Mode)........................................... 8
Table 4 VCxSTOP1 Register Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 5 VCxSTRT1 Bit Field Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 6 Capture and Display Performance ................................................................................... 18
1 Introduction
Digital signal processors (DSPs) have become increasingly important in a wide range of video
and imaging applications, such as machine vision, medical imaging, security monitoring, digital
cameras and printers, and a large number of consumer applications driven by digital video
processing including DVDs, digital TV, and video telephony. These applications are
characterized by requirements for processing flexibility, sophisticated algorithms, and high data
rates. The DM642 is a DSP designed to handle the computational requirements of the above
applications.
The Texas Instruments DM642 has three 20-bit video ports that can be configured for different
video standards, such as BT.656 or, as in the application this document describes, can be used
in raw data capture mode. The video ports are capable of driving encoders for display purposes,
or they can capture data from various decoders and video sources. In the application described
by this document, the video source will be an MT9T001 CMOS Digital Image Sensor by
MicronM Technology, Inc. This application is applicable to other sensors and video A/D
converters having similar interfaces.
The following sections give an overview of the MT9T001 and DM642 video port configured for
raw capture mode operation. These sections describe the physical and logical interfaces, and
provide a sample application proving the discussed system.
Signal
Symbol Name I/O Description
VAAPIX Analog pixel power − Power supply for pixel array, 3.3V
VDD Digital power supply − Power supply for digital block, 3.3V
VAA Analog power supply − Power supply for analog block, 3.3V
AGND Analog ground − Isolated ground for analog block and pixel array.
PIXCLK Pixel clock O Pixel data outputs are valid during the falling/rising edge of this
clock. See the Pixel Clock Control register for options. The fre-
quency is equal to that of Master Clock In.
LINE_VALID Output line valid O This output is high whenever a line of valid pixel data is available
on the data bus (see Read Mode 2 register for options).
CLK_IN Master clock in I Master clock into Sensor (48 MHz maximum).
FRAME_VALID
LINE_VALID_0
LINE_VALID_1
The Sensor data registers are 16 bits wide, so two 8-bit transfers are required when reading or
writing a register. A typical write sequence for writing 16 bits to a register is shown in the figure
below. The sequence begins with a Start bit followed by the Sensor write address. After the
Sensor acknowledges the write address (A), a specific register address is issued, which is the
Column Size register in this example. At this point, the Sensor expects to receive two 8-bit data
transfers (0x02 and 0x7F) to complete the write process.
SCLK
Figure 2. I2C Write to Column Size Register (0x04) with the Value 0x027F
The figure below shows a typical read sequence for reading 16 bits from a register. The
sequence begins with a Start bit followed by the Sensor write address. After the Sensor
acknowledges the write address, a specific register address is issued (Column Size register). A
Start bit is generated again and the Sensor read address is issued. At this point, the Sensor will
transmit two 8-bit data packets, and the read process ends with a No Acknowledge (N) followed
by a Stop bit.
SCLK
Figure 3. I2C Read from Column Size Register (0x04). 0x027F Returned
G R G R G R
B G B G B G
G R G R G R
B G B G B G
G R G R G R
B G B G B G
VPxCTL0 CAPENA I Data capture enable. Data is sampled by the video port when this line is active.
Reserved VCYSTART
15 14 12 11 0
Reserved Reserved. This location is always read as 0. Values written to this field have no effect.
VCVBLNKP This field defines the minimum CAPEN inactive (LOW) time to be interpreted as a vertical blanking period.
When the SSE bit is set and the video capture port is enabled (VCEN set to 1 in the VCxCTL
register), the video port will not start capturing data until after two vertical blanking periods are
detected. The length of a single vertical blanking period is defined by the VCVBLNKP field,
which is in turn defined with respect to the CAPEN signal, i.e., the VCVBLNKP field defines the
minimum CAPEN inactive time to be interpreted as a vertical blanking period. In order to ensure
initial capture synchronization to the beginning of a frame, VCVBLNKP must be assigned a
value larger than the expected horizontal blanking interval and less than half the expected
vertical blanking interval. The figure below highlights this situation.
CAPEN
H H
V
VCVBLNKP
VCVBLNKP
H = Horizontal blanking interval
V = Vertical blanking interval
WARNING:
Frame synchronization is only performed ONCE every time the video capture port is
enabled (VCEN = 1). A noisy CAPEN signal may cause a loss of frame synchronization.
To re-synchronize, the video port must be disabled, then re-enabled.
The method required to setup and operate the video port in raw capture mode will be discussed
later in this document.
CLK_IN 48 MHz
PIXCLK VCLKINA [VPxCLK0]
LINE_VALID CAPENA [VPxCTL0]
D[9:0] VPxD[9:0]
SCLK SCL
SDATA SDA
TRIGGER
GSHT_CTL
FRAME_VALID
STROBE VCLKINB [VPxCLK1]
RESET SYS_RESET CAPENB [VPxCTL1]
STANDBY FID [VPxCTL2]
OE VPxD[19:10]
GND
The FRAME_VALID signal on the Sensor is left unconnected because no input exists on the
DM642 which can take advantage of this signal. However, the FRAME_VALID line is not needed
since the information necessary for proper operation with the DM642 is carried on the
LINE_VALID signal. Recall that the LINE_VALID and FRAME_VALID signals indicate that a line
and frame of valid pixel data is available on the data bus. Because the DM642 samples data
when CAPEN is active, proper video port and Sensor operation requires that the LINE_VALID
signal be connected to the CAPEN signal.
The software interface must ensure that the LINE_VALID signal operates according to the
non-continuous format. Recall that the Read Mode 2 Sensor register can be configured for
different LINE_VALID formats based on the desired vertical blanking operation. For proper
operation, the Read Mode 2 register must be programmed to ensure that the LINE_VALID signal
is inactive during vertical blanking intervals. The figure below illustrates this operation.
FRAME_VALID
LINE_VALID
H = Horizontal blanking
V = Vertical blanking
In the Sensor to DM642 interface described above, the TRIGGER, STROBE, and GSHT_CTL
signals are not used and left unconnected. In an advanced design, these signals can be used to
enable Snapshot Mode operation. In this mode, the TRIGGER signal can be connected to a
GPIO on the DM642 and used to initiate the start of a single frame capture, STROBE can be
used to turn on a flash, and GSHT_CTL can be combined with a mechanical shutter to achieve
simultaneous exposure of all rows in the image. For more information on Snapshot Mode, refer
to Micron’s Data Sheet 2.
Three files were modified to enable raw capture mode operation: _vport.h, vportcap.h, and
vportcap.c (renamed to vportcap_RAW_support.c). These modified files are available for
download with this document. The modified capture configuration structure is shown in the code
segment below.
typedef struct {
Int cmode;
Int fldOp;
Int scale;
Int resmpl;
Int bpk10Bit;
Int hCtRst;
Int vCtRst;
Int fldDect;
Int extCtl;
Int fldInv;
/* RAW CAPTURE INITIALIZATION SPECIFIC
Modify structure to accept Raw Capture mode specific
parameters for SSE Enable/Disable and VCVBLNKP. */
Uint16 sse; /* startup synchronization enable */
Uint16 vcvblnkp; /* minimum CAPEN inactive time to be
interpreted as a vertical blanking period */
Uint16 fldXStrt1;
Uint16 fldYStrt1;
Uint16 fldXStrt2;
Uint16 fldYStrt2;
Uint16 fldXStop1;
Uint16 fldYStop1;
Uint16 fldXStop2;
Uint16 fldYStop2;
Uint16 thrld;
Int numFrmBufs;
Int alignment;
Int mergeFlds;
Int segId;
Int edmaPri;
Int irqId;
} VPORTCAP_Params;
Two parameters (Uint16 sse and Uint16 vcvblnkp) were added to the configuration structure to
ensure that the SSE and VCVBLNKP fields in the VCxSTRT1 register (described in a previous
section) are correctly programmed. All other parameters in the configuration structure are
unmodified and are described in the application report TMS320DM642 Video Port Mini-Driver
(SPRA918). The following are possible settings for the ‘sse’ and ‘vcbblnkp’ parameters.
•
sse: enables or disables startup synchronization
− VPORTCAP_SSE_ENABLE
− VPORTCAP_SSE_DISABLE
vcvblnkp: specifies the minimum CAPEN inactive time to be interpreted as a vertical
• blanking period.
− Any value between 0 and 0xFFF
The code segment below shows the capture configuration structure initialized to enable 8-bit raw
capture mode (progressive) for a resolution of 640x480.
LINE_SZ−1,
NUM_LINES,
LINE_SZ−1,
NUM_LINES,
(LINE_SZ>>3),
4,
128,
VPORT_FLDS_MERGED,
NULL,
EDMA_OPT_PRI_HIGH,
8
};
The following fields are not used for raw capture mode operation and were filled to satisfy the
configuration structure size and parameter requirements.
• scale, resmpl, hCtRst, vCtRst, fldDect, extCtl, fldInv
The following fields must be set to zero and one for proper operation.
• fldXStrt1 = 0
• fldYStrt1 = 1
• fldXStrt2 = 0
• fldYStrt2 = 1
The following fields are initialized with the desired capture resolution.
• fldXStop1: number of pixels per line to capture minus one (line size – 1)
• fldYStop1: number of lines to capture
• fldXStop2: number of pixels per line to capture minus one (line size – 1)
• fldYStop2: number of lines to capture
Because the Sensor captures and outputs data according to a progressive scan, the video port
is configured to operate accordingly.
• fldOp = VPORT_FLDOP_PROGRESSIVE
In order to ensure initial capture synchronization to the beginning of a frame,
• sse = VPORTCAP_SSE_ENABLE.
Recall that when the SSE bit is set and the video capture port is enabled (VCEN set to 1 in the
VCxCTL register), the video port will not start capturing data until after two vertical blanking
periods are detected. The length of a single vertical blanking period is defined by VCVBLNKP,
which must be assigned a value larger than the expected horizontal blanking interval and less
than half the expected vertical blanking interval. Using the frame timing formulas provided in
Micron’s Data Sheet 2, a value of 0xFFF was chosen to satisfy this constraint.
All other fields not mentioned are not raw capture mode specific and are initialized according to
the definitions and restrictions outlined in the TMS320DM642 Video Port Mini-Driver (SPRA918)
application report and the TMS320C64x DSP Video Port/VCXO Interpolated Control (VIC) Port
Reference Guide (SPRU629).
The SAA7105 video encoder on the DM642 EVM can be configured to drive the display on a
monitor. The encoder will generate the necessary RGB and synchronization signals provided
that it is correctly configured and is given data in the expected format. Encoder configuration is
simple with the SAA7105 EDC provided with the Video Port Mini-Driver. The code segment
below shows the configuration structure used to initialize the encoder for SVGA display with data
in the RGB565 input format.
The RGB565 data format is a 16-bit value that represents one pixel. The upper 5, middle 6, and
lower 5 bits make up the red, green, and blue colors respectively. This concept is illustrated in
Figure 12.
Recall that the data output from the Sensor is formatted in a Bayer pattern. Consider the case of
640x480 with 8 bits per pixel of video capture. In this case, each pixel captured by the port will
consist of 8 bits and be stored in a Bayer pattern. The data format provided by the Sensor is
incompatible with the RGB565 data format expected by the decoder and must be converted.
Several methods exist to solve this problem. One such solution is to expand each pixel to
include 8 bits of red, green, and blue by interpolation or filtering, then extract the upper 5, 6, and
5 bits of RGB data and store them in one 16-bit memory location. This conversion technique
effectively converts one plane of 8-bit 640x480 Bayer pattern data into three planes of 8-bit
640x480 RGB data, then to 1 plane of 16-bit 640x480 RGB565 data.
The method used in the Sensor to DM642 interface discussed in this document avoids the color
plane expansion discussed above, but results in a reduction of display resolution. Consider the
4x4 block of Bayer pattern data below. By thinking of each 2x2 block (shaded portion) as a
single pixel of 8-bit red, green, and blue data, the upper 5, 6, and 5 bits of red, green (average
the two green pixels together), and blue can be extracted and stored into 16-bit memory. The
advantage of this algorithm is simplicity, but the disadvantage is a reduction of display
resolution. This algorithm reduces both the horizontal and vertical resolutions by half. In the case
of 640x480 capture, only 320x240 can be displayed. To circumvent a reduction of desired
display resolution, the video port and Sensor can be set to capture twice the desired display
resolution. For example, if a display of 640x480 is desired, capture 1280x960. The price of this
solution is a potential decrease in capture and display performance in terms of frames per
second.
G R G R
B G B G
G R G R
B G B G
• MT9T001_close()
− This function closes the Sensor port and places the Sensor in standby mode.
• MT9T001_ctrl()
− This function issues commands to the Sensor. There are three commands supported by
this function. Other commands can be added by modifying this function according to the
EDC interface standard.
The software example that accompanies this document supports four capture resolutions. Other
capture resolutions can be easily added by modifying the source code. The table below shows
the four capture resolutions supported along with the capture and display performance in terms
of frames per second (fps). The ‘Sensor Out’, ‘Video Port Capture’, and ‘Video Port Display’
columns represent the fps output by the Sensor, captured by the video port, and output to an
SVGA monitor. The routine that counts fps is included with the source code that accompanies
this document. The values in the ‘Sensor Out’ column were calculated according to the Frame
Timing equations documented in the Micron’s Data Sheet 2. The register values for the
resolution settings below are also documented in Micron’s Data Sheet 2.
640x480 94 94 60 320x240
1280x720 39 39 39 640x360
1920x1080 19 19 19 800x540¶
† These rates are possible after compiling with file level optimization on MT9T001_utils.c
‡ The settings for this resolution are not given in the CMOS Digital Image Sensor data sheet. Column Size = 319, Row
Size = 239, Shutter Width = 564 (to remove 60Hz flicker), Horizontal Blanking = 21, Vertical Blanking = 15.
§ The frame rate is low in order to remove 60Hz flicker from artificial lighting conditions. See the CMOS Digital Image
Sensor data sheet for more details on 60Hz flicker.
¶ The display resolution after Bayer to RGB565 conversion is 960x540. In SVGA mode, a maximum of 800x600 lines
can be displayed. Since 800 is less than 960, only 800 pixels per line are displayed.
5 Conclusion
This document describes how to interface the TMS320DM642 to a CMOS Digital Image Sensor
in raw capture mode. A complete example is shown, including hardware and software interfaces.
The software consists of a set of routines that are compatible with the Video Port Mini-Driver and
External Device Control interface. At capture resolutions of 1920x1080, 1280x720, 640x480,
and 320x240, the video display port operates at 19, 39, 60, and 60 frames per second
respectively. This document is accompanied by example software designed to operate with the
TMS320DM642 EVM and is available electronically from the TI website.
6 References
1. Jack, Keith. Video Demystified: A Handbook for the Digital Engineer. Elsevier Science &
Technology Books, April 2001.
2. MT9T001 3-Megapixel CMOS Digital Image Sensor Data Sheet, MicronM Technology, Inc.
3. PCA9540B 2-Channel I2C Multiplexer Data Sheet, Philips Semiconductors
4. SN74CBTLV3257 Low-Voltage 4-Bit 1-Of-2 FET Multiplexer/Demultiplexer, Texas
Instruments
5. TMS320C6000 DSP Inter-Integrated Circuit (I2C) Module Reference Guide (SPRU175)
6. TMS320C64x DSP Video Port/VCXO Interpolated Control (VIC) Port Reference Guide
(SPRU629)
7. TMS320DM642 Video/Imaging Fixed-Point Digital Signal Processor Data Manual
(SPRS200)
8. The TMS320DM642 Video Port Mini-Driver (SPRA918)
Data multiplexing is controlled by switch 1 (SW1) on the schematic. When the switch is off, the
video port can operate in 8, 10, and 20-bit raw capture modes. When the switch is on, the video
port can operate in 16-bit raw capture mode. For 16-bit mode operation, the
DC_EXP_AUDIO_EN# signal on J3 must be connected to 3.3V. Note that the software provided
with this document operates on 8-bit data and assumes single sensor operation on video port 1
by default. For more information on the data multiplexers, see the SN74CBTLV3257 Multiplexer
Data sheet and the TMS320C64x DSP Video Port/VCXO Interpolated Control (VIC) Port
Reference Guide (SPRU629)
To provide access for up to two Sensors, a 2-channel I2C address multiplexer is used
(PCA9540B). Address multiplexing may be necessary since multiple Sensors on a single board
may have the same I2C address. The multiplexer allows each Sensor to be programmed
independently. The necessary address translation is automatically performed in the software and
is based on the naming convention used to allocate and initialize an FVID channel object. Refer
to the Sensor EDC section in this document for a discussion on FVID channel objects. For more
information on the PCA9540B, refer to the PCA9540B 2-Channel I2C Multiplexer data sheet.
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you
permission to use these resources only for development of an application that uses the TI products described in the resource. Other
reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third
party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims,
damages, costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (www.ti.com/legal/termsofsale.html) or other applicable terms available either on
ti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable
warranties or warranty disclaimers for TI products.
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2019, Texas Instruments Incorporated