cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeF4 LTDC minor issues

Tamas Novak
Associate III
Posted on November 16, 2014 at 16:37

- In a comment in stm32f4xx_hal_ltdc.c   HAL_LTDC_ProgramLineInterrupt() is mentioned...but couldn't find such a function. It's not even declared in ''...ltdc.h''.

- In the source of HAL_LTDC_ConfigCLUT function you find

HAL_StatusTypeDef  HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx) {

....

for(counter = 0; (counter < CLUTSize); counter++)   {

    tmp  = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));

    pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);

    pCLUT = (uint32_t *)pcounter;

    /* Specifies the C-LUT address and RGB value */

    __HAL_LTDC_LAYER(hltdc, LayerIdx)->CLUTWR  = tmp;

  }

  

If I use AL44 color schema, only 16 items are used in CLUT. In this situation these 16 items are 0x00, 0x11, 0x22'th etc. of 256 elements of the table.

It was easier to initialize the color table with a smaller and any order array

static uint_32t  LCUT= {0x00000000, 0x11ff0000, 0x2200ff00, 0x330000ff, 0x44ffffff}; //black, colors, white

if code was simply

for(counter = 0; (counter < CLUTSize); counter++)   {

    __HAL_LTDC_LAYER(hltdc, LayerIdx)->CLUTWR  = 

*pCLUT

;

    pCLUT += 

sizeof(*pCLUT);

}

#stm32cubef4-ltdc
5 REPLIES 5
Posted on November 17, 2014 at 14:29

Hi,

  • The name of “HAL_LTDC_ProgramLineInterrupt()�? API is changed to “HAL_LTDC_ProgramLineEvent()�? and the comment must be updated.
  • The inputted color lookup table contain only from 0 to 256 colors and cannot contain the index of the color, for this we have to specify and add the index (CLUT address) before the load. For the AL44 pixel format we can optimize the code to have in input only ordered 16 items as follows:

    for(counter = 0; (counter < 
    CLUTSize
    ); counter++)

    {

    if(hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)

    {

    tmp = (((counter + 16*counter) << 

    24

    ) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));

    }

    else

    { 

    tmp = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));

    }

    pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);

    pCLUT = (uint32_t *)pcounter;

    /* Specifies the C-LUT address and RGB value */

    __HAL_LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;

    }

Thanks for the valuablefeedbacks.

PS:Please Format Code Block - Paintbrush [<>] icon, upper left of Word-in-a-box(tm) interface. Regards, Heisenberg.
Tamas Novak
Associate III
Posted on November 17, 2014 at 19:13

Sorry for dispute:)), but LTDC_LxCLUTWR upper 8 bits is the index itself, so I can address any single one of the 256 CLUT items.
<
br
><
br
>Bits 31:24 CLUTADD[7:0]: CLUT Address<
br
>These bits configure the CLUT address (color position within the CLUT) of each RGB<
br
>value<
br
>Bits 23:16 RED[7:0]: Red value<
br
>These bits configure the red value<
br
>Bits 15:8 GREEN[7:0]: Green value<
br
>These bits configure the green value<
br
>Bits 7:0 BLUE[7:0]: Blue value<
br
>These bits configure the blue value<
br
><
br
>Original solution generates the index, so allows us to 
load the table only from the the beginning, my solution allows the user 
to load the table in any order by direct addressing. The most flexible way to initialize is supplying a given number [1..256] of 32bit values, where upmost 8bit is the index, the other 8-8-8 are the color components.<
br
>For example I'm able to change only the color nr 20 (and leave all the rest untouched), I call<
br
><
br
>uint32_t NewCLUTItem= 0x16000000; //black to color nr 20<
br
>
HAL_LTDC_ConfigCLUT(&hltdc, &NewCLUTItem, 1, 0);<
br
><
br
><
br
>Thank you,<
br
>Tamas

Tamas Novak
Associate III
Posted on November 17, 2014 at 19:22

Sorry..I wouldn't have tried formatting:))

Posted on November 20, 2014 at 16:22

Hi Tamas,

In fact the implementation we have already suggested is generic and allows us to load the CLUT table from the begenning with the 256 items, which is the most used case. Loading the table in any order by direct addressing, can be a specific use case.

Regards,

Heisenberg.

Tamas Novak
Associate III
Posted on November 22, 2014 at 19:32

Thank you, Heisenberg.

My last super-minor realization is maybe a misspell: the callback funtion for line interrupt is HAL_LTDC_LineEve

nC

allback...shouldn't it be LineEve

ntC

allback?

best regards,

Tamas