HardFault error while using GUI_PNG_DrawEx function of stEmWin library.

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • HardFault error while using GUI_PNG_DrawEx function of stEmWin library.

      I have achieved to draw bmp, gif and jpg images with related DrawEx functions of stEmWin library. The library version of stEmWin is 544. My board is STM32F746G-DISCO.

      In order to try png images, I downloaded png library from segger's web site. I imported the source files of the png library(V544) 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. The project is really simple. We are using FATFS without OS. We are trying to show a simple logo.png file inside the SD card. However, we are getting hardfault error. 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. What can be the source of our problem? I could not upload the project because of maximum file size limit. If you have questions, I can give you all details about the project.

      You can also find and download the project from the following link.


      /* 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;
    • Hi,

      PNG decoding requires a lot of RAM, but given that you allocated more than 6MB to emWin, this shouldn't be the problem.

      It could be something wrong with the PNG image itself, have you tried using another PNG image, just to see if that works? You may try with the image I have attached, as this one worked for me.

      Best regards,

      • segger-logo.png

        2.08 kB, 65×33, viewed 44 times