2018-10-05 01:13 AM
Hello
I'm a newbie as STM32. I want to write a program can take picture from camera and save it into SD card when I press a button.
I had finish this, but it's still having problems. The program stop after created one picture, after only one click. I can do it again by call initialize camera one more time.
I had found the cause is because "f_open" command. I try to run program like this below.
..........
..........
--Start camera and display on LCD---
loop{
->wait for the button was pressed.
if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0) //1
{
if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) == FR_OK)
{
f_open(&JPEG_File, "image.jpg", FA_WRITE || FA_CREATE_ALWAYS);
f_close(&JPEG_File);
}
}
}
The camera stop even I didn't do anything. Just creating JPEG file and closing it after pressed the button.
Trying to understand the f_open() function, I think it's related to the line "stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);" into the function disk_initialize() of diskio.c.
When I ignore this line, camera didn't stop. But I still really don't understand what happened.
Anyone know about this problems, please tell me. Why the camera is stop when I create JPEG file, and what should I do for dealing with this problem.
Thanks so much.