the problem of STM32F417 about the Internal Buffer defined in SDRAM memory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-18 06:52 AM
Hello,
I have a STM32F4-EVB-V2 Board with MCU STM32F417IGH6. I want to display a BMP picture from SDcard to TFT LCD. So I have used an example ''Display/LTDC_PicturesFromSDCard'' from one of the STM324xG_EVAL's application. The function has been written as following:void readBmpFile(uint8_t *Address, const char* BmpName){ uint32_t index = 0, size = 0, i1 = 0; uint32_t BmpAddress; if (f_mount(0, &filesystem) != FR_OK) { LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *) ''Could not open filesystem!''); } Delay(10); ret = f_open(&myFile, BmpName, FA_READ); if (ret) { LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *) ''Not exist file!''); }else{ LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *) ''The file content:''); ret = f_read(&myFile, sector, 16, (UINT *)&BytesRead);//30 BmpAddress = (uint32_t)sector; /* Read bitmap size */ size = *(uint16_t *) (BmpAddress + 2); size |= (*(uint16_t *) (BmpAddress + 4)) << 16; /* Get bitmap data address offset */ index = *(uint16_t *) (BmpAddress + 10); index |= (*(uint16_t *) (BmpAddress + 12)) << 16; f_close(&myFile); f_open(&myFile, BmpName, FA_READ); do{ if (size < 256*2){ i1 = size; }else{ i1 = 256*2; } size -= i1; f_read (&myFile, sector, i1, (UINT *)&BytesRead); for (index = 0; index < i1; index++) { *(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress; BmpAddress++; Address++; } BmpAddress = (uint32_t)sector; } while (size > 0); LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *) ''Close the file.''); ret = f_close(&myFile); if (ret) { LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) ''Close file error?''); }else{ LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) ''Close correctly.''); } }}and uint8_t *uwInternelBuffer;int main(){uwInternelBuffer = (uint8_t *)0xC0260000;.......... readBmpFile(uwInternelBuffer, Bmpfile); LCD_DrawBitmap(0,0, uwInternelBuffer);} Everytime, the process goes to ''Address++'', the program is broken down! Is there someone can help me? Thank you very much.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-18 07:16 AM
The board you describe has neither SDRAM nor LTDC
There is no memory at 0xC0000000, the code Hard Faults as a result.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-18 07:48 AM
First of all, I really glad to say thank you for your help, clive1.
The STM32F4-EVB user manual has mentioned:The 4Mbit PSRAM and 512Mbit NAND are connected to FSMC bus of STM32F417IGH6 and The 3.2� TFT color LCD connected to FSMC bus.I have been used them to display ''alphanumeric characters'' but no picture.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-18 12:30 PM
Unfortunately not a board I have, or can invest any time in.
You could perhaps set up the PSRAM to hold the bitmap if the internal memory is not large enough. This isn't the frame buffer to the LCD, so you'd still need to copy the data there. I seem to recall some threads a year or two back where I demo'd the plotting of BMP files of various types on to the 320x240 panels with the controller/frame-buffer integrated on to them.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-19 11:06 AM
I have found an example from one of the projects STM324xG_EVAL. It has a display application named LCD_Paint. It must include a bmp's header eg. #include <stlogo.h> in the main.c. Now I can display a ''stlogo'' picture, but it seems too small. This picture has 9174 bytes and width=80, height=57. Could I have the other way to display a 320x240 picture read from SD card directly?
Thanks #ifndef __STLOGO_H#define __STLOGO_Hconst unsigned char stlogo[9174]={0x42,0x4d,0xd6,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x39,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x03,0x00,0x00,0x00,0xa0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,................................}#include <stlogo.h>.....int main(void){ ........ LCD_Init(); LCD_Clear(LCD_COLOR_WHITE); LCD_DrawBitmap(57,80, (uint8_t *) stlogo); ...... }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-19 11:43 AM
Could I have the other way to display a 320x240 picture read from SD card directly?
So malloc() yourself a buffer, and f_open/f_read the content of the BMP into that buffer, extract the dimensions, and call the plotting function. You appear to have most of the functions, just make sure you have a sufficiently large heap.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-21 10:34 AM
I have used malloc(), but it still doesn't work!
I want to read a BMP picture, it has size 204534 Bytes. so, I declare a dynamic memory as below: uint8_t *ptr=malloc(204534 * sizeof(uint8_t)); then, I call a fuction to read the picture. but the ''ptr'' is always equal to ''0x00000000''? Attached for your reference is Memory area, and the program as fllowing: startup_stm32f40_41xxx.s Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ; <h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Heap_Size EQU 0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit void readBmpFile2(uint8_t *ptr, const char *BmpName) { uint32_t index = 0, size = 0, i1 = 0, i2=0; uint32_t BmpAddress; if (f_mount(0, &filesystem) != FR_OK) { LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *) ''Could not open filesystem!''); } Delay(10); ret = f_open(&myFile, BmpName, FA_READ); if (ret) { LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *) ''Not exist file!''); }else{ LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *) ''The file content:''); ret = f_read(&myFile, sector, 16, (UINT *)&BytesRead);//30 BmpAddress = (uint32_t)sector; /* Read bitmap size */ size = *(uint16_t *) (BmpAddress + 2); size |= (*(uint16_t *) (BmpAddress + 4)) << 16; /* Get bitmap data address offset */ index = *(uint16_t *) (BmpAddress + 10); index |= (*(uint16_t *) (BmpAddress + 12)) << 16; f_close(&myFile); f_open(&myFile, BmpName, FA_READ); do{ if (size < 256*2){ i1 = size; }else{ i1 = 256*2; } size -= i1; f_read (&myFile, sector, i1, (UINT *)&BytesRead); for (index = 0; index < i1; index++) { //*(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress; for(i2=0; i2< 512; i2++){ *(ptr+index*512+i2)= sector[i2]; } BmpAddress++; //Address++; } BmpAddress = (uint32_t)sector; } while (size > 0); LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *) ''Close the file.''); ret = f_close(&myFile); if (ret) { LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) ''Close file error?''); }else{ LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) ''Close correctly.''); } } } int main(void) { uint8_t *ptr=malloc(204534 * sizeof(uint8_t)); char *fileName= ''btest.bmp''; RCC_Config(); LCD_Init(); LCD_Clear(LCD_COLOR_WHITE); LCD_SetTextColor(LCD_COLOR_BLUE); readBmpFile2(ptr, fileName); LCD_DrawBitmap(0,0, (uint8_t *)ptr); } ________________ Attachments : memoryArea.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzYA&d=%2Fa%2F0X0000000bO4%2Fsm_R_aD4ni9aHmM0P9g5nPJohk3DBCP9D9VdR803ZTg&asPdf=false- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-21 11:59 AM
Well that's not going to fit in a 512 byte heap.
You're going to need to configure the FSMC and your external PSRAM in the SystemInit() code within system_stm32f4xx.c. Then add that memory region/size into the memory map, either via the GUI or as a scatter file. You might want to use the scatter file as that would also allow you to direct the heap into that region. May be you can find some external memory examples for your board, or the EVAL series board. Check also with the board vendor for examples.Up vote any posts that you find helpful, it shows what's working..