2014-06-10 11:29 AM
Hello,
Relevant information: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
2014-06-11 02:51 AM
Problem solved. Updated the first post with working code.
2014-11-16 08:26 PM
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?2014-11-17 07:46 AM
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?