DCMI not transmiting to UART
Im new to the STM32Cube IDE and trying to make a project with CDMI, the minimal idea is to take a picture on button click and send it to a PC via UART.
This is not working, the I2C comunication is working and im getting both HAL_DCMI_LineEventCallback() and HAL_DCMI_VsyncEventCallback() triggering. The HAL_DCMI_FrameEventCallback() is never called
and im always getting Buffer Error since (i belive) the image size is 320*240*3 and my buffer can only reach 65535.
How can i aproach this problem?
Output
UNSAM Space Snap
Author:
Marco A. Mecha
PID: 76, VER: 73
Camera init........ OK
Camera config...... OK
Starting Capture....
Buffer Error
Capture End
Image size: 65535 bytes
Image Resolution: 481 x 22
DCMI Errors: 0
DCMI Frame Nr: 0
Relevant snipet of main()
while(status != RET_OK){
status = ov7670_init(&hdcmi, &hdma_dcmi, &hi2c2);
HAL_Delay(10);
}
my_printf("Camera init........ OK\r\n");
while(status != RET_OK){
status = ov7670_config(OV7670_MODE_QVGA_RGB565);
HAL_Delay(10);
}
my_printf("Camera config...... OK\r\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
if (!HAL_GPIO_ReadPin(USER_Btn_GPIO_Port, USER_Btn_Pin)) {
my_printf("\r\nStarting Capture....\r\n");
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, SET);
ov7670_stopCap();
bufferPointer = 0;
headerFound = 0;
LineEventNr = 0;
VsyncEventNr = 0;
memset(frameBuffer, 0, sizeof frameBuffer);
ov7670_startCap((uint32_t) frameBuffer);
HAL_Delay(1000);
HAL_DCMI_Stop(&hdcmi); // Stop the DCMI
while (1) {
if (bufferPointer >= BUFFER_SIZE ) {
my_printf("Buffer Error \r\n");
break;
}
if (frameBuffer[bufferPointer] == 0xFF){
if (headerFound == 0 && frameBuffer[bufferPointer + 1] == 0xD8) {
my_printf("Found header of JPEG file \r\n");
headerFound = 1;
}
if (headerFound == 1 && frameBuffer[bufferPointer + 1] == 0xD9) {
my_printf("Found EOF of JPEG file \r\n");
bufferPointer = bufferPointer + 2;
break;
}
}
bufferPointer++;
}
// HAL_UART_Transmit_DMA(&huart2, frameBuffer, bufferPointer);
HAL_Delay(100);
my_printf("\r\nCapture End\r\n");
my_printf("Image size: %u bytes \r\n", bufferPointer);
my_printf("Image Resolution: %d x %d \r\n", LineEventNr/VsyncEventNr, VsyncEventNr);
my_printf("DCMI Errors: %d \r\n", ErrorNr);
my_printf("DCMI Frame Nr: %d \r\n", FrameEventNr);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, RESET);
HAL_Delay(500); // Debounce delay
}
