SCT Camera Interface Design With LPC1800 and LPC4300: Rev. 1.2 - 3 June 2014 Application Note
SCT Camera Interface Design With LPC1800 and LPC4300: Rev. 1.2 - 3 June 2014 Application Note
SCT Camera Interface Design With LPC1800 and LPC4300: Rev. 1.2 - 3 June 2014 Application Note
Application note
Document information
Info
Content
Keywords
SCT SGPIO camera module LPC1800 LPC4300 DMA Cortex-M3 CortexM0 Cortex-M4
Abstract
This application note demonstrates the camera interface design with the
SCT peripheral on the LPC1800 and LPC4300.
AN11365
NXP Semiconductors
Revision history
Rev
Date
1.2
Description
20140603
Added a separate project for lpc1857 with its own header and drivers
Added the hardware design doc to zipfile
Added recommendation to use debugger with Pre-reset
1.1
20130711
20130625
Initial version.
Contact information
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: [email protected]
AN11365
Application note
2 of 15
AN11365
NXP Semiconductors
1. Introduction
LPC1800 is the Cortex-M3 series MCU from NXP which runs up to 180 MHz and has a
wide selection of advanced peripherals, like the State Configurable Timer (SCT), SPI
Flash Interface (SPIFI), LCD Controller, EMC and high-speed USB. LPC4300 is the dual
core series MCU from NXP which includes an industry leading Cortex-M4 core and a
Cortex-M0 coprocessor both running up to 204 MHz. The State Configurable Timer
(SCT) is available on the LPC1800 and the LPC4300 series MCUs. All discussions about
the SCT implementation in this application note apply to both LPC4300 and the
LPC1800. To simplify this discussion, we will only mention LPC1800 unless it is a
LPC4300 unique feature. The sample project has been tested with both MCB1800 and
MCB4300 development boards.
The SCT interface is a powerful digital configurable interface on the LPC1800 series
MCU. With 16 events, 32 states, 8 inputs, and 16 outputs plus the match/capture
capability, the SCT interface can easily input or output complex waveforms. In this
application, we create the states and events based on the cameras timing signals such
that the SCT can sample the camera output at the correct timing.
The demonstration hardware is a Keil MCB1800 board with an add-on daughter board
available from NXP. The picture of an assembled board is shown in Fig 1.
Fig 1.
Some of the highlights in this camera module design include a demonstration of the
flexibility of the SCT system as well as a very low bandwidth usage of the LPC1800
MCU. This application note is related to AN11343 (SGPIO camera interface design with
LPC4300) in that the same camera sensor is used in both application notes with a similar
CPU bandwidth usage.
AN11365
Application note
3 of 15
AN11365
NXP Semiconductors
Fig 2.
AN11365
Application note
4 of 15
AN11365
NXP Semiconductors
Fig 3.
AN11365
Application note
5 of 15
AN11365
NXP Semiconductors
Fig 4.
AN11365
Application note
6 of 15
AN11365
NXP Semiconductors
Fig 5.
Fig 6.
Application note
7 of 15
AN11365
NXP Semiconductors
Fig 7.
Fig 8.
Debugger setup
AN11365
Application note
8 of 15
AN11365
NXP Semiconductors
Fig 9.
In this implementation, the SCT is configured to be a single 32-bit timer with 8 nonsynchronized inputs for the SCT from the camera interface. The bus clock is used as the
SCT and prescaler clock. Below is a snippet of the code used for SCT general
configuration in function SCTInit() from source code Cam_OV7670.c.
1
2
The other timer control registers are disabled as they are not used in this implementation.
3
4
5
6
7
Application note
9 of 15
AN11365
NXP Semiconductors
The falling edge of the VSync signal as well as the falling edge of the Href signal
serve as the event to trigger the SCT transit to wantH.
3. Receiving a line of data
This is named inH as indicated in below state transition diagram in Fig 10. The
rising edge of the Href signal triggers the SCT to transition to inH. Within the
inH state, each PCLK triggers a SCT event to request the DMA transfer. At the
rising edge of the VSync, the DMA is initialized to transfer the first line of the
image to the SDRAM. At each falling edge of Href, the DMA transfer is initialized
to transfer a new line of data to the SDRAM. Please refer to the SCT interrupt
service routine SCT_IRQHandler() in Cam_OV7670.c for details of this
implementation.
AN11365
Application note
10 of 15
AN11365
NXP Semiconductors
Below is a snippet of the code used for SCT events and states definition and
configuration in function SCTInit().
8
9
10
11
12
13
typedef enum
{
ctst_wantV = 0, // wait for VSYNC
ctst_wantH = 1, // wait for HSYNC
ctst_inH = 2,
// in a HSYNC pulse ctst_skipV = 3,
}enum_CamTimSt;
As a single timer is used UNIFY is 1 in the CONFIG register, only the _L bits in the
SCT state register is used. Notice that every frame starts from state: wantV
pSCT->STATE_L = ctst_wantV;
Next the state transition events are defined.
14
15
16
17
18
19
20
21
22
23
typedef enum
{
ctev_vsyncRise = 0,
// Rising edge of VSync
ctev_vsyncRiseInSkip, // Used only if frame skip is enabled,
rising edge of VSync in skipped frame.
ctev_vsyncFall,
// Falling edge of VSync
ctev_hsyncRise,
// Rising edge of HSync
ctev_hsyncFall,
// Falling edge of HSync
ctev_pxclkRise,
// Rising edge of PCLK
}enum_ctev;
Subsequently, the event state mask register and control register of each event are
configured. Please refer to SCTInit() for details on the configuration.
AN11365
Application note
11 of 15
AN11365
NXP Semiconductors
5. Conclusion
The State Configurable Timer (SCT) interface on the LPC1800 and LPC4300 series
MCUs features flexible timing configuration with states and events control. These
features make the SCT a perfect choice to handle state controlled input data stream like
the camera interface design demonstrated in this application note. With the help of the
GPDMA, this camera interface uses only 8 % of the CPU bandwidth with a 180 MHz
Cortex-M3 core in the LPC1800 series MCU. Users are encouraged to port this
implementation to their custom application without the cost of a dedicated camera
interface. The SCT interface is a truly value added peripheral to NXPs MCU families.
With more NXP parts providing the SCT interface, users can greatly simplify their
complicated applications in power conversion, lighting, motor control, and audio
applications, etc.
AN11365
Application note
12 of 15
AN11365
NXP Semiconductors
6. Legal information
6.1 Definitions
Draft The document is a draft version only. The content is still under
internal review and subject to formal approval, which may result in
modifications or additions. NXP Semiconductors does not give any
representations or warranties as to the accuracy or completeness of
information included herein and shall have no liability for the consequences
of use of such information.
6.2 Disclaimers
Limited warranty and liability Information in this document is believed to
be accurate and reliable. However, NXP Semiconductors does not give any
representations or warranties, expressed or implied, as to the accuracy or
completeness of such information and shall have no liability for the
consequences of use of such information. NXP Semiconductors takes no
responsibility for the content in this document if provided by an information
source outside of NXP Semiconductors.
In no event shall NXP Semiconductors be liable for any indirect, incidental,
punitive, special or consequential damages (including - without limitation lost profits, lost savings, business interruption, costs related to the removal
or replacement of any products or rework charges) whether or not such
damages are based on tort (including negligence), warranty, breach of
contract or any other legal theory.
Notwithstanding any damages that customer might incur for any reason
whatsoever, NXP Semiconductors aggregate and cumulative liability
towards customer for the products described herein shall be limited in
accordance with the Terms and conditions of commercial sale of NXP
Semiconductors.
Right to make changes NXP Semiconductors reserves the right to make
changes to information published in this document, including without
limitation specifications and product descriptions, at any time and without
notice. This document supersedes and replaces all information supplied prior
to the publication hereof.
Suitability for use NXP Semiconductors products are not designed,
authorized or warranted to be suitable for use in life support, life-critical or
safety-critical systems or equipment, nor in applications where failure or
malfunction of an NXP Semiconductors product can reasonably be expected
to result in personal injury, death or severe property or environmental
damage. NXP Semiconductors and its suppliers accept no liability for
inclusion and/or use of NXP Semiconductors products in such equipment or
applications and therefore such inclusion and/or use is at the customers
own risk.
Applications Applications that are described herein for any of these
products are for illustrative purposes only. NXP Semiconductors makes no
representation or warranty that such applications will be suitable for the
specified use without further testing or modification.
6.3 Trademarks
Notice: All referenced brands, product names, service names and
trademarks are property of their respective owners.
Customers are responsible for the design and operation of their applications
and products using NXP Semiconductors products, and NXP
AN11365
Application note
13 of 15
AN11365
NXP Semiconductors
7. List of figures
Fig 1.
Fig 2.
Fig 3.
Fig 4.
Fig 5.
AN11365
Application note
Fig 6.
Fig 7.
Fig 8.
Fig 9.
Fig 10.
14 of 15
AN11365
NXP Semiconductors
8. Contents
1.
2.
3.
3.1
3.2
3.3
4.
4.1
4.2
4.3
4.3.1
4.3.2
5.
6.
6.1
6.2
6.3
7.
8.
Introduction ......................................................... 3
Camera interface overview ................................. 4
SCT camera module overview............................ 4
Hardware connections ....................................... 5
High level flow chart ........................................... 6
Description of the contents included in this
application note .................................................. 7
SCT camera interface design ............................. 8
General introduction ........................................... 8
Camera interface SCT states and transition
analysis .............................................................. 9
Specific notes for the SCT camera interface
design .............................................................. 11
Notes on GPDMA usage .................................. 11
Notes on double buffering in video
reception/transmission ..................................... 12
Conclusion ......................................................... 12
Legal information .............................................. 13
Definitions ........................................................ 13
Disclaimers....................................................... 13
Trademarks ...................................................... 13
List of figures..................................................... 14
Contents ............................................................. 15
Please be aware that important notices concerning this document and the product(s)
described herein, have been included in the section 'Legal information'.