---
# System prepended metadata

title: OV7670 Dev log

---

OV7670 Dev log
===
### 2022/3/15
##### ==Goal==: Try to take one snapshot
```c=
DCMI_HandleTypeDef hdcmi;
DMA_HandleTypeDef hdma_dcmi;
#define QVGA 320*240*2/4
#define FRAME_BUFFER 0xc0000000
while(1)
{
    if (HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin) == GPIO_PIN_RESET){
        __HAL_DCMI_ENABLE_IT(&hdcmi, DCMI_IT_FRAME);
        //memset((void *)frameBuffer, 0, sizeof(frameBuffer));// reset buffer
        HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t) FRAME_BUFFER, QVGA);// Start DCMI, will start DMA interrupt inside this function.
        printf("buffer size: %d \n", FRAME_BUFFER);
    }
}

```
##### ==Result==
only receive this
![](https://i.imgur.com/mZiUPxE.png)
Failed.

### 2022/3/16
##### ==Goal==: Try to understand sequence of DMA and DCMI interrupt

```c
while(1){
    if (HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin) == GPIO_PIN_RESET){
    while (HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin) == GPIO_PIN_RESET){};
    latch = true;/* latch is a boolean variable to avoid entering this if statement twice 
                    since the MCU is fast than our finger */
    }
    if (latch){
        printf("Enter Latch\n");
        __HAL_DCMI_ENABLE_IT(&hdcmi, DCMI_IT_FRAME);
        printf("Enable DCMI interrupt\n");
        //memset((void *)frameBuffer, 0, sizeof(frameBuffer));// reset buffer
        HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, (uint32_t) FRAME_BUFFER, QVGA);// Start DCMI, will start DMA interrupt inside this function.
        printf("Start DMA\n");
    }
}

```
##### ==Result==
![](https://i.imgur.com/n3QihPE.png)
1 means DCMI is ready,2 is busy.
