cancel
Showing results for 
Search instead for 
Did you mean: 

How the image send from camera to computer? Help me

muhammet
Associate II
Posted on August 12, 2013 at 13:21

I have a project with OV7670 with stm32f4-discovery. My OV7670 has 16 pins and without fifo. I want to the get one image with camera and I have to send this image to computer. But I don't have any idea. Help me.

My code:

/**

  ******************************************************************************

  * @file    main.c

  * @author  MCD Application Team

  * @version V1.0.0

  * @date    18-April-2011

  * @brief   Main program body

  ******************************************************************************

  * @attention

  *

  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS

  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE

  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY

  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING

  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE

  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

  *

  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>

  ****************************************************************************** 

  */

/* Includes ------------------------------------------------------------------*/

&sharpinclude ''stm32f4xx.h''

&sharpinclude ''usart.h''

&sharpinclude ''LCD/LCD.h''

&sharpinclude ''camera/dcmi_OV7670.h''

/** @addtogroup STM32F2xx_StdPeriph_Examples

  * @{

  */

/** @addtogroup IOToggle

  * @{

  */

void LCD_CS_ResetBits(void);

void Delay(__IO uint32_t nTime);

void TimingDelay_Decrement(void);

static __IO uint32_t TimingDelay;

uint32_t fps=0;

uint32_t disfps=0;

uint32_t fpsbuff[5];

/**

  * @brief  Main program

  * @param  None

  * @retval None

  */

int main(void)

 OV7670_IDTypeDef OV7670ID;

 RCC_ClocksTypeDef SYS_Clocks;

 uint8_t i=0;

  /*!< At this stage the microcontroller clock setting is already configured,

       this is done through SystemInit() function which is called from startup

       file (startup_stm32f2xx.s) before to branch to application main.

       To reconfigure the default setting of SystemInit() function, refer to

        system_stm32f2xx.c file

  */

 if (SysTick_Config(SystemCoreClock / 1000))

   {

     /* Capture error */

     while (1);

   }

 RCC_GetClocksFreq(&SYS_Clocks);

 USART_Configuration();

 //USART_NVIC_Config();

 printf(''\r\nSYSCLK:%dM\r\n'',SYS_Clocks.SYSCLK_Frequency/1000000);

 printf(''HCLK:%dM\r\n'',SYS_Clocks.HCLK_Frequency/1000000);

 printf(''PCLK1:%dM\r\n'',SYS_Clocks.PCLK1_Frequency/1000000);

 printf(''PCLK2:%dM\r\n'',SYS_Clocks.PCLK2_Frequency/1000000);

 LCD_Initializtion();

   LCD_Clear(Red);

 

 DCMI_OV7670_Init();

  

 /*Set LCD direction*/  

 LCD_WriteReg(0x0011,0x6068);

 LCD_SetCursor(0,0);

 Prepare_Write_RAM();

                           

 /* 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);

     

 

 while (1)

 {

  Delay(1000);

  fpsbuff[i]=fps;

    fps=0;

  i++;

  if(i==5)

  {

   disfps=(fpsbuff[0]+fpsbuff[1]+fpsbuff[2]+fpsbuff[3]+fpsbuff[4])/5;

   printf(''FPS:%d\r\n'',disfps);

   i=0;

  }        

 }

}

void Delay(__IO uint32_t nTime)

{

  TimingDelay = nTime;

  while(TimingDelay != 0)

  {}

}

void TimingDelay_Decrement(void)

{

  if (TimingDelay != 0x00)

  {

    TimingDelay--;

  }

}

void LCD_CS_ResetBits(void)

{

 GPIO_InitTypeDef  GPIO_InitStructure;

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

 //LCD_CS PD7

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

 GPIO_Init(GPIOD, &GPIO_InitStructure); 

 GPIO_ResetBits(GPIOD , GPIO_Pin_7);   //CS=0;

}

&sharpifdef  USE_FULL_ASSERT

/**

  * @brief  Reports the name of the source file and the source line number

  *         where the assert_param error has occurred.

  * @param  file: pointer to the source file name

  * @param  line: assert_param error line source number

  * @retval None

  */

void assert_failed(uint8_t* file, uint32_t line)

{

  /* User can add his own implementation to report the file name and line number,

     ex: printf(''Wrong parameters value: file %s on line %d\r\n'', file, line) */

  /* Infinite loop */

  while (1)

  {

  }

}

&sharpendif

/**

  * @}

  */

/**

  * @}

  */

/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

 

#best-forum-software-ever
8 REPLIES 8
Posted on August 12, 2013 at 16:13

You've got an LCD attached?

Seems to be some F2 code/comments mixed in.

Can you send the data via the serial port, or USB perhaps?

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/How%20the%20image%20send%20from%20camera%20to%20computer%20Help%20me&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=7]Related?

If this is home work or course project work, you should discuss with your instructor
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
muhammet
Associate II
Posted on August 13, 2013 at 10:11

Thank you for answer. The problem is that I don't know how can I get data from camera. After that I want to send this data to computer. Finally I will use interface to see image.

Posted on August 13, 2013 at 18:42

What does the documentation say?

Have you reviewed any DCMI examples, or ones for boards that have camera attachments?

STM32F4xx_DSP_StdPeriph_Lib_V1.1.0\Project\STM32F4xx_StdPeriph_Examples\DCMI\DCMI_CameraExample

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
muhammet
Associate II
Posted on August 14, 2013 at 15:45

I get the data from DMA and I send this data to array. Last of this I send all of data to computer via usart. But I see only ''0''.

DMA_DeInit(DMA2_Stream1);

 

 DMA_InitStructure.DMA_Channel = DMA_Channel_1; 

  DMA_InitStructure.DMA_PeripheralBaseAddr = DCMI_DR_ADDRESS;

 DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) buffer_A;

  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;

  DMA_InitStructure.DMA_BufferSize = sizeof(buffer_A);

  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_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);

    

 for(i=0 ; i<640*16 ; i=i+2)

 {

 printf(''%d'',buffer_A[i]);

 }

Posted on August 14, 2013 at 16:24

The size is in 32-bit words, not bytes, you'll need to scale the sizeof()

Does the buffer have visible content in the debugger? Is any data getting transferred via DMA from the DCMI? Try putting a fill pattern in there if you are not sure.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dthedens23
Associate II
Posted on August 14, 2013 at 16:24

wait until the DMA is finished?

dthedens23
Associate II
Posted on August 14, 2013 at 16:25

Funny.  I get a double post when I get a web page error

Posted on August 14, 2013 at 16:44

Funny.  I get a double post when I get a web page error

One of the errors occurs when it tries to display your new post. Hit back (some browsers retain your edit, FireFox), or open the forum in another tab and confirm if the post stuck.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..