cancel
Showing results for 
Search instead for 
Did you mean: 

Hi I am doing a project using STM32L496G-Discovery and ov5640 sensor, what I am triying to do is capture data with a resolution of 320x240 and JPEG format and save it to the sd card however when i open the file created I don't see anything.

FTila.1
Associate II
 
3 REPLIES 3
FTila.1
Associate II

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

}

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.

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

Hi @Community member​ 

The size of the image is 90 Kbytes the same size as the mximum of the buffer. I think the problem could be that the header of JPEG is missing. I save the the data in a txt file you take a look to the file if you can