This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5638: Store large array, and convert image to C data array

Part Number: MSP430F5638

Designed a custom SBC using an MSP430F5638 which is running fine. Uses a 480x272 pixel color TFT LCD which is also running fine for setting colors, displaying text (as graphical fonts), and doing XY plots. I'm trying to display a jpg image on the LCD - and used LCD Image Converter to convert a small image into a global array of unsigned ints. The image .h file is 3MB in size.

The array dimensions are correct: 480 x 272 = 130,560 pixels where each pixel needs a group of 3 hex numbers - 3 x 130,560 = 391,680

static const unsigned int BE950020[391680] = {

    0x00ed, 0x0074, 0x000c, 0x00f9, 0x007b, 0x000d, 0x00fe, 0x0080, 0x0008, 0x00f8, 0x0081, 0x0003, 0x00df, 0x0075, 0x0000, 0x00c9, 0x0066,

...

...

};

 

How is it even possible to build this application for a MCU with 256KB of FLASH + globals, and 16KB of RAM? Initially I was getting the error #69 Array is Too Large. Changed memory model from: Large / Restricted / Globals to: Large / Large / Globals, and changed the array type from unsigned long int to unsigned int - and it builds and loads to the SBC ok. Is it just loading what it can into FLASH and throwing the rest away? After the garbage image display, I can change the background color, so the program is still running ok, just the image display is junk. 

The LCD is filled with garbage - snow.

Does TI have an alternative to LCD Image Converter, a tool to convert an image file: jpg, bmp, png, etc. into a C data array of pixel values?

  • First, change the unsigned int into a uint8_t, that saves half.

    Next, you might have to look at some sort of lossless compression such as RLL.

  • Thanks Keith,

    The LCD needs it in 16 bit format

  • You can always cast it as you send it to the LCD.

  • The LCD uses a 16 bit parallel GPIO interface for max speed, and wants to see packed data as shown below. How would I cast the 8 bit data to match this?

    LCD_write_data(0xFF00);    // red, green - these 3 statements set a single pixel - example is fixed at red, typically it's a mix of all 4 hex digits.

    LCD_write_data(0x00FF);    // blue, red

    LCD_write_data(0x0000);    // green, blue

  • I am pretty sure the Graphics Reformer is geared towards GRLib which expects images like this:

    which isn't very helpful. And doesn't look like it is formatted the way you want.

    To use an image in bytes with your functions simply bit fiddle:

    uint16_t arg = ((byteMSB<<8) | byteLSB)

  • Keith, Thanks for replying

  • An Update

    I don’t know anyway of “smashing” a 3MB file down to what – 30KB, small enough to fit into what is left of the 256KB Flash in the MCU? The MCU Flash has to hold the program and all global vars - Please confirm.

     Without adding external memory with either a MicroSD card or separate Flash chip, there is no way to deal with a data file this big – Please confirm.

     Does TI have an equivalent to the Russian LCD Image Converter?

     I’ve done a lot of google searching for image converters and they are all: image to image, not image to data. Do you know of any alternatives to LCD Image Converter?

  • Hi Ted,

    I do not know of a way you would be able to compress 3MB to 30KB inside the part with the remaining memory. Is there a reason you wouldn't be able to use an external flash/ SD card to pull the image data?

    Regards,

    Luke

  • Hi Luke, 

    Thanks for confirming that it's not possible to do that. I do have a uSD card interfaced to one MCU, but I haven't developed the code for it yet. That will solve the memory problem. Do you know of any alternatives to LCD Image Converter?

  • The closest thing MSP430 offers would be the Graphics Library and the Image Reformer that is associated. Here is the link to the graphics library, you can also download the image reformer separately. 

    https://www.ti.com/tool/MSP-GRLIB#downloads 

    Regards,

    Luke 

  • Thanks Luke, I'll take a look at them

  • Thanks Keith & Luke for your posts.

    Displaying an image on an embedded LCD was far more complex than I imagined. Even if the LCD is already working for everything else. Below is a summary of what I discovered.

    You can’t display an image file: jpg, bmp, png, tiff, directly on an LCD. It has to be converted to a C/C++ data array, stored in a text .c or .h file, and written via code to the LCD’s pixels. 

    Even a 20-40 MB PSD file which has been converted in Photoshop to a 90 KB jpg file, will create a 3MB .c or .h text data file for a 480 x 272-pixel color image. Of course, size varies with number of colors used. 

    High end 16 or 32 bit MCU’s - msp430f5638, or msp432p401r only support 256 KB of Flash for program plus global data – no way to fit a 3MB array into them. 

    Using a uSD card to store the data array will solve the memory problem. A separate Flash RAM chip would work too, but less versatile, and not on my SBC. But I haven't developed the uSD code yet. 

    LCD Image Converter (LIC) and TI's Image Reformer (IR) both work for creating text .c or .h data arrays. Image Reformer looks like it might generate smaller files.

    Could also open, dissect, and read the image file and convert it via code to a C/C++ data array – see Bob Grant’s online course which I've only viewed the first 15 minutes. Writing your own code to essentially do what LIC or IR are doing.

    https://www.youtube.com/watch?v=exjzGMX4fqs

**Attention** This is a public forum