Question

I work with MCB1700 evaluation board. It has (320 x 240) TF LCD Display. IDE: Keil uvision4 4.03q. My task is to download picture from PC to MCB1700, display it on LCD
and download on USB-stick (that connects to the board). I need 320*240*2 = 153600 bytes of memory. MCB1700 has only 64kB SRAM, and 512kB of on-chip Flash memory. Obviously, I must store picture in Flash memory.

As I understand, I should bind pointer directly to memory address.

/* Base addresses                                                             */
#define LPC_FLASH_BASE        (0x00000000UL)         //beginning address of on-chip Flash
#define LPC_IMAGE_ADDR          (LPC_FLASH_BASE + 0x10000)
#define ImagePtr                ((unsigned short        *) LPC_IMAGE_ADDR       )

//read-write operations
ImagePtr[0] = 0x0124;           //First pixel
…
ImagePtr[320*240] = 0xFA37;     //Last pixel
unsigned short A = ImagePtr[0];

Is it correct? I have a doubts because of Target’s options. enter image description here

Flash memory’s area is defined like Read/Only IROM1. Does it mean that we can only read data from Flash and must change Memory area in IROM and IRAM fields to perform writing operation? For example in such way: enter image description here

Was it helpful?

Solution

You might do better to let the compiler/linker decide where to place the image in Flash:

static const unsigned short Image[320*240] = { <image data> } ;

will place Image as an array in ROM1 memory.

You cannot write directly to flash memory, it is normally read-only, and while write operations are word oriented, a word cannot be written unless it is previously erased and erasure is page or sector oriented - so it is somewhat more complex to manage that your example code.

In my suggestion above I have included an initialiser. Now it is obviously impractical to manually initialise 320*240 elements, but it is simple enough to write a PC based tool that will generate the necessary initialiser code directly from an image file.

Alternatively, if the image cannot be static, you might reserve part of your Flash for the image and then write code to write the flash memory and where necessary erase pages from data downloaded from a serial port or USB for example. In this case the Flash memory must be page aligned and comprise of an integer multiple of Flash pages.

For flexibility you should not rely on the target dialog settings and instead create a custom scatter file, where you can then create a custom section and allocate your image memory to it using armcc extension __attribute__ variable qualifiers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top