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
DCMI driver for STM32F4xx/F2xx
Re: DCMI driver for STM32F4xx/F2xx
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
So finally a camera module for ChibiOS/GFX will can take shape (as soon as the ToDo list allows it, of course -.-).
~ Tectu
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: DCMI driver for STM32F4xx/F2xx
Note that there is an errata regarding DCMI+DMA on the F4, you should carefully check that it does not affect you.
Giovanni
Giovanni
Re: DCMI driver for STM32F4xx/F2xx
Hello.
I tried this driver on my STM32F429 discovery board with MT9D131 sensor.
The driver is not working properly!
First of all:
must be:
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.
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.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: DCMI driver for STM32F4xx/F2xx
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
Giovanni
Re: DCMI driver for STM32F4xx/F2xx
Hi, thanks. I forgot that DMA is able to do so
because most problems are with MT9D131 sensor and I suffered with it most.