Skip to main content
CSeng.1
Visitor II
June 15, 2020
Question

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

  • June 15, 2020
  • 1 reply
  • 1296 views

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;

}

This topic has been closed for replies.

1 reply

sirius506
Associate III
June 19, 2020

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