Giving eyes to a micro controller: DCMI interface on an STM32F4

It has been another long hiatus between posts. But, I have managed to learn and do quite a bit of stuff in these last few months and it has been rewarding to say the least.

Recently, I have had to work on an embedded platform for image processing. It was quite a big deal as I had never worked with any sort of embedded platform before and the kind of work is quite different from what I have done before. So, my first task was to interface a camera with a microcontroller. After consulting with my friends, Shrenik and Vinod, I decided to use a microcontroller which provides a hardware camera interface instead of writing the complete firmware from scratch for an ATMEGA as I had planned on doing earlier.

After some research, I ended up selecting the well known STM32F4 series of microcontrollers. The STM32F407 is a high powered μC with an ARM Cortex M4 processor running at 168 MHz. The development board available has 1 Mb of onchip flash and 192 kB of SRAM. After playing with GBs of RAM, it sure was tough to be excited about a few kB of SRAM, but it was a different challenge to solve the problem using as few resources as possible. The STM32F407 features a a hardware camera interface known as DCMI ( Digital Camera Interface). It is compatible with a huge range of camera modules on the market.

I had also decided to use the OV2640 camera module as it features an on-board JPEG encoder and is quite well documented. After a few days of familiarizing with the basic concepts and fiddling around with the standard peripherals library from  STM, I came across this amazing implementation, OpenMV. I found it extremely helpful to understand the intricacies of image processing on embedded systems.

The primary issues that I faced while working on this project were:

  • Understanding DCMI and DMA interfaces of the STM32 controller.
  • Understanding the communication and synchronization between the camera and the controller.
  • Clocks and STM’s unique proposition of allowing us to turn off peripheral clocks when required for low power usage.

I am going to be blogging about my experiences regarding my foray into the world of micro-controllers and camera control soon. Until then, here are a few images that I captured with my setup.

test4test2

Advertisements

4 comments

  1. i am working on something similar..could you possibly put the code up?

    the problem with me is that i am a total beginner as i only just started programming anything outside Arduino IDE. currently using the IAR workbench to code the stm32f407vg discovery board.

    my process plan so far has been to:
    1. learn how to program through I2C
    2. learn how to use the DCMI port
    3. learn how to use the DMA to control the FSMC (planning to use an external SRAM)
    4. put all things together and make the cam

    1. Hey,

      Its a very good plan but it might take you a quite a lot of time. Instead, I suggest you use the OpenMV project as a base for your project. It is based on the same STM board, and it is one of the best projects I have so far seen on camera interfacing using the DCMI interface. It provides a very good understanding of the flow as well familiarizes you with the STMCube code flow.

      I am sorry but I can not put my code up as it is still under development. I hope to do so soon.

      P.S. : Use the STMCubeMX software. It is a godsend for beginners.

    1. I have run a modified version of the OpenMV code on the F4 discovery board. I have not tried the IDE though I am sure that a few modifications in the source should make it work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s