2018-06-06 12:40 PM
I am building code to show all jpeg images in SD card and print their names. I use the STM32F746 Discovery. The jpeg decoder crashes after the first image. The Jpg decoder stays at hard fault loop. If I comment the jpeg_decode(&viili, IMAGE_WIDTH, _aucLine, Jpeg_CallbackFunction); line, code works but of course no images are shown.
Main.c looks like this
/* Includes ------------------------------------------------------------------*/ #include 'main.h' FATFS SDFatFs; /* File system object for SD card logical drive */ FIL viili; /* File object */ FRESULT res; DIR dir; static FILINFO fno; char SDPath[4]; /* SD card logical drive path */ RGB_typedef *RGB_matrix; uint8_t _aucLine[2048]; uint32_t offset = 0; uint32_t line_counter = 239; /* Private function prototypes -----------------------------------------------*/ static void SystemClock_Config(void); static void LCD_Config(void); static uint8_t Jpeg_CallbackFunction(uint8_t* Row, uint32_t DataLength); static void CPU_CACHE_Enable(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program * @param None * @retval None */ int main(void) { /* Enable the CPU Cache */ CPU_CACHE_Enable(); HAL_Init(); /* Configure the system clock to 200 MHz */ SystemClock_Config(); /*##-1- LCD Configuration ##################################################*/ LCD_Config(); /*##-2- Link the micro SD disk I/O driver ##################################*/ if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0) { /*##-3- Register the file system object to the FatFs module ##############*/ if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) == FR_OK) { res = f_findfirst(&dir, &fno, '', 'ima*.jpg'); /* Start to search for photo files */ res = f_open(&viili,&fno.fname[0] , FA_READ); while (res == FR_OK && fno.fname[0]) { /* Repeat while an item is found */ /*##-5- Decode the jpg image file ##########################################*/ jpeg_decode(&viili, IMAGE_WIDTH, _aucLine, Jpeg_CallbackFunction); /*##-4- Close the JPG image ################################################*/ f_close(&viili); BSP_LCD_DisplayStringAtLine(2, (uint8_t*)fno.fname); HAL_Delay(2000); res = f_findnext(&dir, &fno); /* Search for next item */ } f_close(&viili); } } /* Infinite loop */ while (1) { } } �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Note: this post was migrated and contained many threaded conversations, some content may be missing.
2018-06-10 02:59 PM