cancel
Showing results for 
Search instead for 
Did you mean: 

I am getting HardFault error while using GUI_PNG_DrawEx function of stEmWin library. What is wrong with my project?

CSeng.1
Associate

I have achieved to draw bmp, gif and jpg images with related DrawEx functions of stEmWin library. The library version of stEmWin is 544. In order to try png images, I downloaded png library from segger's web site. I imported the source files of the png library into my project succesfully. When I try to call GUI_PNG_DrawEx function, I am getting hardfault error.

You can find my project in the attachments. We are using STM32F746G-DISCO board. The project is really simple. We are using FATFS without OS. We need to use png image files in our product. If someone helps us, we will be really happy.

Our get_data function for PNG is like this.

/* Private functions ---------------------------------------------------------*/

int APP_GetData_PNG(void * p, const U8 * * ppData, unsigned NumBytesReq, U32 Off)

{

FIL* file;

uint32_t NumBytesRead;

U8   * pData;

 pData = (U8 *)*ppData;

file = (FIL *) p;

// Set file pointer to the offset location

f_lseek(file, Off);

// Read data into buffer

f_read(file, pData, NumBytesReq, (UINT*)&NumBytesRead);

// Set data pointer to the beginning of the buffer

// Return number of available bytes

return NumBytesRead;

}

1 REPLY 1
sirius506
Associate III

When decoding PNG file, I guess your code is accessing DRAM memory area.

If this guess is correct, then you may encounter HardFault caused by unaligned memory access.

See below article for further explanation and possible solutions.

http://www.keil.com/support/docs/3777.htm