AnsweredAssumed Answered

STM32Cube L0 V1.1.0 Bug

Question asked by degterev.victor.001 on Aug 1, 2015
Latest reply on Aug 3, 2015 by qwer.asdf
I'm using 32L0538DISCOVERY board and STM32Cube L0 V1.1.0.
Firstly, why are the pictures declared as "static"??? It produces more code and use a lot of data RAM. Just replace all the occurrences of "static" in "menu_res.c" to "const":

static uint8_t Background_pic[] = {
const uint8_t Background_pic[] = {
and so on.

It frees about 3k of your RAM. Simple magic, isn't it?
Next look in the "gde021a1.c", function "gde021a1_DrawImage":

301         uint8_t pixels_4_grey[4];
327         pixels_4_grey[j] &= 0xFC;

There is no initialization between these lines of pixels_4_grey array. It placed in stack and may contain any garbage from its previous incarnations. It would be not so bad if it does not form the data_res variable later in code with logic summing (face palm here). I strongly recommend to create standalone function with name like "Convert4pixels_bw_to_gray" and place there this code:

uint8_t Convert4pixels_bw_to_gray( uint8_t pixels_4 )
   int i;
   uint8_t pixels_4_grey;

   // We do not need to initialize pixels_4_grey because of it has 8-bit length and
   // shifts 2x4=8 bits during process
   for ( i=0; i<4; i++ ){
          pixels_4_grey <<= 2;               // Left shift fills 2 LSBs with zeros
          if ( (pixels_4 & 0x01) == 0 ){  // White bit in picture
                pixels_4_grey |= 0x03;       // Fill 2 LSBs with maximal intensity level
          pixels_4 >>= 1;                        // Go to the next picture bit
   return( pixels_4_grey ); // Now we have 4 grey pixels

- lower code;
- lower data (1 byte for pixels_4_grey instead of 4 and so on);
- bug with uninitialised pixels_4_grey eliminated.