2022-03-13 04:03 AM
2022-03-13 04:10 AM
This is the function i am using to capture data
void capture_img (void){
uint8_t pbuffer[MAX_PICTURE_BUFF];
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_SNAPSHOT , (uint32_t) pbuffer, MAX_PICTURE_BUFF/4);
HAL_Delay(300);
char fn[11];
n++;
memset(fn, 0, 11);
sprintf(fn, "Img_%02d.jpg",n);
f_open(&SDFile, fn, FA_CREATE_ALWAYS | FA_WRITE);
res = f_write(&SDFile, pbuffer, sizeof(pbuffer), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
Error_Handler();
}
else
{
f_close(&SDFile);
}
}
And this is the DCMI CONFIGURATION
void MX_DCMI_Init(void)
{
/* USER CODE BEGIN DCMI_Init 0 */
/* USER CODE END DCMI_Init 0 */
/* USER CODE BEGIN DCMI_Init 1 */
/* USER CODE END DCMI_Init 1 */
hdcmi.Instance = DCMI;
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW;
hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME;
hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
hdcmi.Init.JPEGMode = DCMI_JPEG_ENABLE;
hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL;
hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD;
hdcmi.Init.LineSelectMode = DCMI_LSM_ALL;
hdcmi.Init.LineSelectStart = DCMI_OELS_ODD;
if (HAL_DCMI_Init(&hdcmi) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN DCMI_Init 2 */
/* USER CODE END DCMI_Init 2 */
}
2022-03-13 06:03 AM
What is the size of the resultant files?
Does the data look to match the data bytes you wrote into the file?
Could you write some known patterns, or check via a file viewer?
Perhaps you have a small, working, JPEG image you can embed into the firmware as a test image, and write that to the card.
2022-03-16 12:20 PM