MARMEX-VB (MARY-VB) Camera module

Camera module operation library. mbed controls and transfer data via I2C and SPI interfaces

Hello World

Import programMARMEX_VB_Hello

A "Hello" program for MARMEX_VB library. This application may work 40pin type mbed platforms ;) This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1)

Library

Import libraryMARMEX_VB

MARMEX-VB : "Mary Camera module" library

Pinout

Datasheet

http://www.marutsu.co.jp/contents/shop/marutsu/datasheet/0000000200314097.pdf

Notes

Information

日本語による解説が,こちらのページ /teams/CQ-Publishing/wiki/MARMEX_VB-library に用意されています.
Japanese page is available in next URL : /teams/CQ-Publishing/wiki/MARMEX_VB-library

A camera module operation library for MARMEX-VB(MARY-VB). This "Hello program" shows captured data displayed on OLED screen (MARMEX-OB).

The hello program can run on 40pin type mbed modules, i.e. mbed-LPC1768, mbed-LPC11U24 and TG-LPC11U35-501.

Information

Test program for this library has been published also. The test programs can operate full feature of the library and enable to save captured data into BMP file. The test program only works on "mbed-LPC1768".

Import programMARMEX_VB_test

MARMEX_VB test application program. This application works on "mbed NXP LPC1768" only. This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with MARMEX_OB module (on slot1)

Next picture shows "MARMEX_VB_Hello" code is running on TG-LPC11U35-501 with MARMEX-OB (OLED screen) on "MAPLE mini type-B (MARM03-BASE)" baseboard
/media/uploads/nxpfan/dsc_0513.jpg

Another program "MARMEX_VB_test" can test operations of this library (see next picture). The image on the screen is mirrored with alpha blending (mirroring and alpha-blending features are implemented in application program).
/media/uploads/nxpfan/dsc_0506_-1-.jpg

Information

SPI speed optimization options are available (20-June-2014)

MARMEX-VB library and MARMEX_OB_oled.h have option settings for faster data transfer.
This option enables FIFO on the SPI interface to accelerate consecutive data read/write.
The FIFO enabled code gives 2x speed data transfer. The frame-rate/field-rate can be improved much.

In default option setting, the FIFO is not enabled to keep code compatibility to mbed-SDK.
This FIFO optimization is an "ad-hoc" tuning for specific hardware and setting. Please be careful if you enable those.

The default setting is "LOOP_UNROLL".
LOOP_UNROLL is moderate tuned code based on mbed-SDK API. This setting should work on any mbed environment without any special care.

MARMEX_VB.cpp

//#define   LINE_READ_OPT   NO_OPTIMIZATION
#define     LINE_READ_OPT   LOOP_UNROLL
//#define   LINE_READ_OPT   USING_SSP_FIFO

MARMEX_OB_oled.h

//#define   LINE_WRITE_OPT  NO_OPTIMIZATION
#define     LINE_WRITE_OPT  LOOP_UNROLL
//#define   LINE_WRITE_OPT  USING_SSP_FIFO

Code samples above is default setting in both files

"NO_OPTIMIZATION" and "LOOP_UNROLL" is compatible to mbed-SDK. So it may work any MCUs/boards which supports SPI interface.

"USING_SSP_FIFO" is the option for using FIFO. It does work on LPC1768, LPC11U24 and LPC11U35.

MARMEX_VB.cpp

//#define   LINE_READ_OPT   NO_OPTIMIZATION
//#define   LINE_READ_OPT   LOOP_UNROLL
#define     LINE_READ_OPT   USING_SSP_FIFO

MARMEX_OB_oled.h

//#define   LINE_WRITE_OPT  NO_OPTIMIZATION
//#define   LINE_WRITE_OPT  LOOP_UNROLL
#define     LINE_WRITE_OPT  USING_SSP_FIFO

Code samples above is FIFO enables settings

The "USING_SSP_FIFO" enabled code will access to peripheral registers, i.e. bypassing the mbed-SDK layer.
The code is expecting to use the SPI port at pins of p5, p6 and p7 on the mbed (LPC1768, LPC11U24 and LPC11U35 based mbed boards). If you need to use other SPI ports, modification should be done on next source files: "MARMEX_VB.cpp" and "MARMEX_OB_oled.h". Code sample is shown below.

MARMEX_VB.cpp

#define     SSP_AUTO_SELECTION  //  for demo setup on "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1)
//#define   SSP_USE_SSP0
//#define   SSP_USE_SSP1

Peripheral block selector. User don't need to edit this part if SPI uses p5, p6 and p7 pins

"SSP_AUTO_SELECTION" will choose appropriate SSP block (SSP0 or SSP1) by code itself. User don't need to change this as far as p5, p6 and p7 pins are used for SPI (on those boards).
"SSP_USE_SSP0" and "SSP_USE_SSP1" are available to select the SSP block manually.

To change the sample program to use the FIFO follow next steps.

  1. open MARMEX_VB.cpp and edit the code.
    comment out "#define LINE_READ_OPT LOOP_UNROLL" and enable "#define LINE_READ_OPT USING_SSP_FIFO".
  2. Open MARMEX_OB_oled.h and edit the code.
    comment out "#define LINE_WRITE_OPT LOOP_UNROLL" and enable "#define LINE_WRITE_OPT USING_SSP_FIFO".
  3. Don't need to edit "#define SSP_AUTO_SELECTION" in both source files.
    If you need to select the SSP block manually, choose SSP_USE_SSP0 and SSP_USE_SSP1 in each source files.
  4. Compile the code for the target board and run it.

Field-rate/frame-rate difference with those options are shown below.

platforminterlacednon-interlaced
mbed LPC1768 (FIFO option)15 field/s10 frame/s
mbed LPC1768 (default option)10 field/s7.5 frame/s
mbed LPC1768 (no optimization)7.5 field/s5.0 frame/s
mbed LPC11Uxx (FIFO option)10 field/s7.5 frames/s
mbed LPC11Uxx (default option)6.0 field/s3.75 frames/s
mbed LPC11Uxx (no optimization)5.0 field/s3.0 frames/s

Information

Acknowledgement and references

The MARMEX-VB module has been designed by Mr.Shirasaka.
Special thanks to him for providing this great module and all its design information.
Detail information is available on a magazine "Transistor Gijutu: July issue, 2014".

These all library and sample programs for the mbed are based on Mr.Shirasaka's original code which is written for TG-LPC11U35-501 with LPCXpresso-IDE.
The sample code is available on http://toragi.cqpub.co.jp/Portals/0/download/2014/TR1407C.zip (1.3MB).