cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved] DCMI on the 32F429IDISCOVERY

paguiar32
Associate
Posted on June 10, 2014 at 20:29

Hello,

Relevant information:
  • The camera is the OV76
  • I am supplying power through the USB port of my laptop.
  • Signals look fairly well with a scope.
  • Feeding the camera with the HSE divided by two (MCO2), using camera's PLL x6 to get 24 MHz.
I have disabled board's LCD and configured the DCMI pins with the following code:

GPIO_InitTypeDef GPIO_Init_Structure;
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE(); 
__GPIOC_CLK_ENABLE();
__GPIOF_CLK_ENABLE();
__GPIOD_CLK_ENABLE();
__GPIOE_CLK_ENABLE();
__GPIOG_CLK_ENABLE();
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Alternate= GPIO_AF13_DCMI; 
GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Pin = GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_9 | GPIO_PIN_10;
HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_7;
HAL_GPIO_Init(GPIOB, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_8;
HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_3;
HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6;
HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_11;
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
/* This is to ensure CS line wired to the gyro and LCD remain up */
GPIO_Init_Structure.Mode = GPIO_MODE_INPUT;
GPIO_Init_Structure.Pull = GPIO_PULLUP;
GPIO_Init_Structure.Pin = GPIO_PIN_1 | GPIO_PIN_2;
HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure);
/* This is to ensure LCD enable line wired remains low */
GPIO_Init_Structure.Pull = GPIO_PULLDOWN;
GPIO_Init_Structure.Pin = GPIO_PIN_10;
HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure);

DMA and DCMI are being configured as follows. I tried using STM32CubeF4 peripheral library but I could not get it to work and decided work directly on the registers to spot the error (yet to be done).

/* DMA and DCMI interrupts */
DMA2->LIFCR = 0xffffffff; 
/* Make sure all the IF are cleared */
DMA2->HIFCR = 0xffffffff; 
DCMI->ICR = 0x1f;
HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); 
/* Enable interrupts */
HAL_NVIC_EnableIRQ(DCMI_IRQn);
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); 
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
/* DMA2 configuration and intialization */
__DMA2_CLK_ENABLE();
__DCMI_CLK_ENABLE();
DMA2_Stream1->CR &= 0xf0100000;
while
(DMA2_Stream1->CR & 1){} 
/* Wait until DMA is disabled */
DMA2_Stream1->NDTR = (uint32_t)(IMG_W*IMG_H/2);
/* Number of data transfers */
DMA2_Stream1->PAR = (uint32_t)(&(DCMI->DR));
DMA2_Stream1->M0AR = (uint32_t)(&(dcmi_buff[0])); 
/* DMA address registers */
DMA2_Stream1->M1AR = (uint32_t)(&(dcmi_buff[0]));
DMA2_Stream1->CR |= 
/* Channel [0,7] */
1<<25| \
/* Mburst */
0<<23| \
/* Pburst */
0<<21| \
/* Current target */
0<<19| \
/* Double buffer */
0<<18| \
/* Priority [0,3] */
3<<16| \
/* Per inc offset (0= %Psize) */
1<<15| \
/* Mem size (0b10=32bits) */
2<<13| \
/* Periph size (0b10=32bits) */
2<<11| \
/* Memory increment */
1<<10| \
/* Periph increment */
0<< 9| \
/* Circular mode */
1<< 8| \
/* Dir (0b00 == P2M) */
0<< 6| \
/* Periph flow controller */
0<< 5| \
/* Transfer complete IE */
1<< 4| \
/* Half transfer IE */
0<< 3| \
/* Transfer error IE */
0<< 2| \
/* Direct mode error IE */
0<< 1| \
/* Stream EN/Ready */
0<< 0; 
DMA2_Stream1->FCR |= 
/* FIFO error IE */
1<< 7| \
/* Direct mode disable */
1<< 2| \
/* FIFO thres (1/4)*(X+1)*/
3<< 0;
DMA2_Stream1->CR |= 1; 
/* Enable */
while
(!(DMA2_Stream1->CR & 1)); 
/* Wait until DMA is enabled */
/* DCMI configuration and intialization */
DCMI->CR &= 0xffffb000; 
/* Clear all non-reserved bits */
while
(DCMI->CR & 0x00004000); 
/* Wait until peripheral is disabled */
DCMI->CR |= 
/* Extended data 00 = 8 bit*/
0<<10| \
/* Frame capture 00 = all */
0<< 9| \
/* VSPOL*/
1<< 7| \
/* HSPOL */
0<< 6| \
/* PCK polarity */
1<< 5| \
/* Embedded syncro */
0<< 4| \
/* JPEG */
0<< 3| \
/* Crop*/
0<< 2| \
/* Capture mode, 0 = continuous */
0<< 1| \
/* Capture enable */
1<< 0; 
DCMI->IER = 
/* LINE_IE */
1<<4| \
/* VSYNC_IE */
1<<3| \
/* ERR_IE */
0<<2| \
/* OVR_IE */
0<<1| \
/* FRAME_IE */
0<<0;
DCMI->CR |= 0x00004000; 
/* Enable DCMI */
while
(!(DCMI->CR & 0x00004000)); 
/* Wait until enabled */

Thank you very much. #32f429idiscovery-dcmi-dma
3 REPLIES 3
paguiar32
Associate
Posted on June 11, 2014 at 11:51

Problem solved. Updated the first post with working code.

vincent_au_93
Associate
Posted on November 17, 2014 at 05:26

Hi,

I am trying to implement OV7670 DCMI with STM32F429 DISCOVERY and I am stuck as I cannot get the DMA working. I saw that you disable LCD onboard. Is there any particular reason to do this? I am using LCD without LTDC so is that a problem?

Posted on November 17, 2014 at 16:46

I saw that you disable LCD onboard. Is there any particular reason to do this? I am using LCD without LTDC so is that a problem?

Like the STM32F429I-DISCO is awfully pin constrained, and the DCMI pins clash?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..