AnsweredAssumed Answered

modify httpserver_netconn with CMOS sensor

Question asked by Simon. Lee on Apr 13, 2012
Latest reply on Jun 25, 2015 by ali.affan
Hi, everybody:

First of all, thanks 
the friends who previously assisted.
I already can connecting and accessing my platform. (It seems httpserver was fine.)
Now, I try to add my CMOS sensor into this program which base on official sample code.

But, I can't see any image on my TFT LCD. It seems DCMI didn't work(I also use DMA2 to transfer data to my TFT LCD).

I'm sure that the program portion of the CMOS settings is normal. Because it can work independently.

I list my main code at below. Does anyone can give my some suggestions? 
My platform is STM32F207. 

int main(void)
{
  
#ifdef SERIAL_DEBUG
  DebugComPort_Init();
#endif
  SRAM_Init();
  Reset_OV9655_Config();//reset OV9655 
  LCD_LED_Init(); //Initialize LCD and Leds
  ETH_BSP_Config(); // configure ethernet (GPIOs, clocks, MAC, DMA)
  LwIP_Init(); // Initialize the LwIP stack
  http_server_netconn_init(); // Initialize web server 
#ifdef USE_DHCP
  xTaskCreate(LwIP_DHCP_task, "DHCPClient", configMINIMAL_STACK_SIZE, NULL,DHCP_TASK_PRIO, NULL); /* Start DHCPClient */
#endif   

  DCMI_OV9655_Start();
  vTaskStartScheduler(); // Start scheduler
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );


void DCMI_OV9655_Start(void)
{
  LCD_Clear(Black);
  LCD_DisplayStringLine(LINE(2), "   Camera Init..");
  DelayX(100);
  /* OV9655 Camera Module configuration */
  if (DCMI_OV9655Config() == 0x00)
  {
    LCD_DisplayStringLine(LINE(2), "Camera Init OK!!");
    /* LCD Display window */
   #if defined (QQVGA_SIZE)
    LCD_SetDisplayWindow(_X(60), _Y(80), 120, 160); 
   #elif defined (QVGA_SIZE)
    LCD_SetDisplayWindow(_X(0), _Y(0), 240, 320);
   #endif
    LCD_WriteRAM_Prepare(); 


    /* Start Image capture and Display on the LCD *****************************/
    /* Enable DMA transfer */
    DMA_Cmd(DMA2_Stream1, ENABLE);


    /* Enable DCMI interface */
    DCMI_Cmd(ENABLE); 


    /* Start Image capture */ 
    DCMI_CaptureCmd(ENABLE);    
  }
  else
  {
    LCD_SetTextColor(LCD_COLOR_RED);


    LCD_DisplayStringLine(LINE(2), "Camera Init.. fails");    
    LCD_DisplayStringLine(LINE(4), "Check the Camera HW ");    
    LCD_DisplayStringLine(LINE(5), "  and try again ");    
  
    STM_EVAL_LEDOff(LED1);
    STM_EVAL_LEDOn(LED3);


    /* Go to infinite loop */
    while(1)
   {
   }      
  }
}

void DCMI_Config(void)
{
  DCMI_InitTypeDef DCMI_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  DMA_InitTypeDef  DMA_InitStructure;
  
  /* Enable DCMI GPIOs clocks */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | 
                         RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOE, ENABLE); //Enable correspond GPIO


  /* Enable DCMI clock */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); //Enable DCMI block clock


  /* Connect DCMI pins to AF13 ************************************************/
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_DCMI);     //PA6 -> DCMI_PIXCK
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_DCMI);     //PA4 -> DCMI_HSYNC


  GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_DCMI);     //PB6 -> DCMI_D5
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_DCMI);     //PB7 -> DCMI_VSYNC
                                                                           
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_DCMI);     //PC6 -> DCMI_D0
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_DCMI);     //PC7 -> DCMI_D1
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_DCMI);     //PC8 -> DCMI_D2
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_DCMI);     //PC9 -> DCMI_D3
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_DCMI);     //PC11 -> DCMI_D4


  GPIO_PinAFConfig(GPIOE, GPIO_PinSource5, GPIO_AF_DCMI);     //PE5 -> DCMI_D6
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource6, GPIO_AF_DCMI);     //PE6 -> DCMI_D7
  
  /* DCMI GPIO configuration **************************************************/
  /* DCMI_HSYNC,DCMI_PIXCK(PA4/6) PA4 -> DCMI_HSYNC, PA6 -> DCMI_PIXCK */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_6;  
  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);


  /* D5,DCMI_VSYNC(PB6/7) PB6 -> DCMI_D5, PB7 -> DCMI_VSYNC */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;  
  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(GPIOB, &GPIO_InitStructure);
 
  /* D0..D4(PC6/7/8/9/11) PC6..9 -> DCMI_D0..D3, PC11 -> DCMI_D4 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | 
                                GPIO_Pin_9 | GPIO_Pin_11;
  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(GPIOC, &GPIO_InitStructure);


  /* D6,D7(PE5/6) PE5 -> DCMI_D6, PE6 -> DCMI_D7 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6;
  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(GPIOE, &GPIO_InitStructure);


  /* DCMI configuration *******************************************************/ 
  DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous; // repeatedly process frames
  DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;
  DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling; // read data on clk rising edge
  DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High; // data valid on vsync high
  DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_High; // data valid on hsync high
  DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;
  DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;
  
  DCMI_Init(&DCMI_InitStructure);


  /* Configures the DMA2 to transfer Data from DCMI to the LCD ****************/
  /* Enable DMA2 clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);  
  
  /* DMA2 Stream1 Configuration */  
  DMA_DeInit(DMA2_Stream1);


  DMA_InitStructure.DMA_Channel = DMA_Channel_1;// in reference maual only DMA2_Stream1/Channel1 can for DCMI function
  DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;     
  DMA_InitStructure.DMA_Memory0BaseAddr = FSMC_LCD_ADDRESS;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
  DMA_InitStructure.DMA_BufferSize = 100;//BufferSize = 1 by PeripheralDataSize_Word(32b) =32b=4B=2pixel. means 4byte transfers one time
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//external address increase disable
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; //RAM address increase disable
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; 
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; 
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA_Mode_Normal ; 
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  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