STM32h743 and OV7670 with DCMI
Hi,
I know there are plenty of similar topics on here but most are unresolved and when they are resolved the OP never posts about it.
So I am creating code through STM32CubeIDE for DCMI with DMA (with help from here).
I'm using the NUCLEO board.
The OV7670 is properly connected to the controller and is outputting correct HREF, VSYNC and PCLK signals for QVGA and RG565. I've previously used this camera without DCMI and a different controller successfully so I am familiar with its signals.
D0-D7 are checked with an oscilloscope and are outputting data.
HAL_DCMI_Start_DMA returns no errors and the DMA1_Stream0_IRQHandler is firing regularly.
Whenever I disconnect either of the signal pins, HAL_DCMI_Start_DMA returns error.
The problem is that my buffer is never written and keeps the value 0 at all times.
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
char hak[10];
uint32_t Im_size = 0;
uint8_t FRAME_BUFFER[320 * 240 * 2];
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ETH_Init();
MX_USB_OTG_FS_PCD_Init();
MX_DCMI_Init();
MX_DMA_Init();
MX_USART3_UART_Init();
MX_TIM3_Init();
MX_I2C2_Init();
/* USER CODE BEGIN 2 */
HAL_Delay(1000);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
HAL_Delay(300);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_1, GPIO_PIN_RESET);
HAL_Delay(100);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_1, GPIO_PIN_SET);
HAL_Delay(300);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
HAL_Delay(500);
if (OV_Config()) {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
sprintf(hak, "ERROR\n");
HAL_UART_Transmit(&huart3, (const uint8_t *)hak, strlen(hak), 10);
}
else {
sprintf(hak, "OK\n");
HAL_UART_Transmit(&huart3, (const uint8_t *)hak, strlen(hak), 10);
}
Im_size = 38400;
HAL_Delay(1000);
FRAME_BUFFER [0] = 0xFF;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
sprintf(hak, "%d\n", HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT, FRAME_BUFFER, Im_size));
HAL_UART_Transmit(&huart3, (const uint8_t *)hak, strlen(hak), 10);
for (int i=0;i<10;i++) {
sprintf(hak, "%d\n", FRAME_BUFFER[i]);
HAL_UART_Transmit(&huart3, (const uint8_t *)hak, strlen(hak), 10);
}
HAL_Delay(2000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}I even switched places between MX_DCMI_Init(); and MX_DMA_Init(); as someone else had suggested but that did nothing.
Thanks