AnsweredAssumed Answered

DCMI: pixel clock issues

Question asked by josvm on Feb 18, 2015
Latest reply on Feb 23, 2015 by josvm
Hi Guys

I' trying to get an image with DCMI module. So, I set up the camera sensor for a square test pattern (a grid of 16 white pixels and 16 black pixels). I get the data with the DMA and the grid obteined was 2x16pixels (2 horizontal and 16 vertical). I'm lossing pixels... I verify the output of the camera and this send 16x16. I don't know where is the problem. 36MHz pixelclock, the datasheet says 54MHz maximum. 


Could someone help me to resolve my problem?. I'm using a STM32F429IG to 1.8V. I'm using the internal cristal. HCLCK = 168MHz.


Here is my configuration code. The main code is just an infinite loop.






void OVxxxx_HW_Init(void)
{
     DCMI_InitTypeDef DCMI_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
     DMA_InitTypeDef  DMA_InitStructure;
     DCMI_CROPInitTypeDef DCMI_CROPInitStructure;
     NVIC_InitTypeDef NVIC_InitStructure;
     


  /*** Configures the DCMI GPIOs to interface with the OVxxxx camera module ***/
  /* Enable DCMI GPIOs clocks */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | 
                         RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOE |
                                                             RCC_AHB1Periph_GPIOH, ENABLE);


       /**DCMI GPIO Configuration  
  PE1   ------> DCMI_D3               -
  PE0   ------> DCMI_D2               -
  PB8   ------> DCMI_D6               -
  PC12   ------> DCMI_D9          -
  PE4   ------> DCMI_D4               -
  PE6   ------> DCMI_D7               -
  PB7   ------> DCMI_VSYNC     -
  PB6   ------> DCMI_D5               -
  PC10   ------> DCMI_D8          -
  PA10   ------> DCMI_D1          -
  PA9   ------> DCMI_D0               -
  PH8   ------> DCMI_HSYNC     -
  PA6   ------> DCMI_PIXCK      -
  */
       /* Connect DCMI pins to AF13 */
     GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_DCMI);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_DCMI);


     GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI);
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI);
     GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_DCMI);
     
     GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_DCMI);
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_DCMI);


  GPIO_PinAFConfig(GPIOE, GPIO_PinSource0, GPIO_AF_DCMI);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource1, GPIO_AF_DCMI);
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource4, GPIO_AF_DCMI);
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource6, GPIO_AF_DCMI);


  GPIO_PinAFConfig(GPIOH, GPIO_PinSource8, GPIO_AF_DCMI);
     
     /* DCMI GPIO configuration */
  /*  */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_9 | GPIO_Pin_10; // | GPIO_Pin_4;          //STM32F407: On ajoute PA4 pour HSYNC
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
     
     /* */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;           
  GPIO_Init(GPIOB, &GPIO_InitStructure);
     
     /*  */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10 | GPIO_Pin_12;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
     
     /*  */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_6;
  GPIO_Init(GPIOE, &GPIO_InitStructure);
     
//  /* HSYNC */          //STM32F429IG
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_Init(GPIOH, &GPIO_InitStructure);
     
     /***************************/
     
       /*** Configures the DCMI to interface with the OVxxxx camera module ***/
  /* Enable DCMI clock */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE);


  /* DCMI configuration */ 
  DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_SnapShot; 
  DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;
  DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Rising;
  DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; 
  DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_Low; 
  DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;
  DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_10b; 


     DCMI_Init(&DCMI_InitStructure);
     
     DCMI_CROPInitStructure.DCMI_VerticalStartLine = 0;                //
  DCMI_CROPInitStructure.DCMI_HorizontalOffsetCount = 0;      //
  DCMI_CROPInitStructure.DCMI_VerticalLineCount = 127;                //
  DCMI_CROPInitStructure.DCMI_CaptureCount     = 31;               //
  DCMI_CROPConfig(&DCMI_CROPInitStructure);                                                                                  
     DCMI_CROPCmd(ENABLE);
     
     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
  NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;  
  NVIC_Init(&NVIC_InitStructure);
     //--------------------------------------------------------
     
     
  /* Configures the DMA2 to transfer Data from DCMI */
  /* Enable DMA2 clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
  
  /* DMA2 Stream1 Configuration */
  DMA_DeInit(DMA2_Stream1);


  DMA_InitStructure.DMA_Channel = DMA_Channel_1;  
  DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;     
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&y; 
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
  DMA_InitStructure.DMA_BufferSize = 2048; 
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;     //
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;  //
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //
  DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; //
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; //
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; //
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; //


     
  DMA_Init(DMA2_Stream1, &DMA_InitStructure);


}

 

Outcomes