DCMI driver for STM32F4xx/F2xx

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
EwanC
Posts: 4
Joined: Thu Nov 01, 2012 11:56 pm

DCMI driver for STM32F4xx/F2xx

Postby EwanC » Wed Apr 24, 2013 1:48 am

Hi all,

I've been working on a DCMI driver for STM32F4xx. Have sent code to a couple of people who PMed about it, so thought it'd be good to post a thread so we can ensure no duplication of effort.

Currently, the driver is 'mostly' working, with a demo application using TCM8230MD included in testhal\. I don't seem to be getting the DCMI end of frame interrupt (but do get DMA transfer complete interrupts). Also seem to be losing the occasional byte in the image, which results in random colour changes and BMP viewing applications complaining about the header length field being wrong.

I don't recommend that this be used yet, have released it more for others with an interest in DCMI development.

Code can be found at https://github.com/EwanColdicott/ChibiOS.

Will post when I've been able to fix the issues above.

Cheers,
Ewan

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby Tectu » Wed Apr 24, 2013 5:50 am

A working DCMI HAL driver for ChibiOS/RT? No way! Thank you very much!
So finally a camera module for ChibiOS/GFX will can take shape (as soon as the ToDo list allows it, of course -.-).


~ Tectu

User avatar
Giovanni
Site Admin
Posts: 13086
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 759 times
Been thanked: 638 times
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby Giovanni » Wed Apr 24, 2013 7:35 am

Note that there is an errata regarding DCMI+DMA on the F4, you should carefully check that it does not affect you.

Giovanni

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby Tectu » Sun Apr 28, 2013 5:27 pm

Do we have any news on this?


~ Tectu

alexblack
Posts: 251
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 29 times
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby alexblack » Tue Nov 19, 2013 12:29 am

Hello.
I tried this driver on my STM32F429 discovery board with MT9D131 sensor.
The driver is not working properly!
First of all:

Code: Select all

os/hal/platforms/stm32f4xx/dcmi_lld.h
...
48 #define STM32_DCMI_CR_CAPTURE   DCMI_CR_CRE
...

must be:

Code: Select all

...
48 #define STM32_DCMI_CR_CAPTURE   DCMI_CR_CAPTURE
...

Also the polarity of sync signals and configuation bits are inverted (thaks ST for "excellent" docs): i.e. if sync is positiv polarity then config bit mus be cleared.
Another problem is DMA - it has maximum transfer size 65535 dwords (I do not understand why 32-bit system has 16-bit DMA counters). For my 2Mpixel sensor this is too litle. I solved this problem by using soft counter on DMA end transfer interrupt but MCU speed too low to universally solve this and transfer shunks must be synchronized with horizontal sync (i.e. must be multiple of image width).
In dcmi_lld_serve_dma_rx_interrupt there is no difference on reason of interrupt: Vsync interrupt not the same the end of capture!
In the end I was able to make it work. It also requires carefully handle the errors. Also I added counter of captured bytes for capturing unkwown data sizes (for example frame in jpeg format) but can''t understaned why it differ from real data size.
I found this link useful http://blog.frankvh.com/2011/08/19/stm32f2xx-digital-camera-interface-dcmi/ it help me.

User avatar
Giovanni
Site Admin
Posts: 13086
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 759 times
Been thanked: 638 times
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby Giovanni » Tue Nov 19, 2013 9:20 am

You may use a small circular buffer with DMA with interrupts at half and end buffer like the ADC does, then have a thread that copies the data out of the half buffers triggered by callbacks. You may also process the data directly without first copying it.

Giovanni

alexblack
Posts: 251
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 29 times
Contact:

Re: DCMI driver for STM32F4xx/F2xx

Postby alexblack » Tue Nov 19, 2013 3:39 pm

Hi, thanks. I forgot that DMA is able to do so :) because most problems are with MT9D131 sensor and I suffered with it most.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 1 guest