AnsweredAssumed Answered

K70 LCDC wrapping the graphic window

Question asked by Slawek Nowak on Nov 26, 2015
Latest reply on Dec 16, 2015 by Earl Orlando Ramirez Sanchez

Hello everybody,

 

I've tried to use graphic window in the LCD controller built in the K70, but I have some troubles.

Screen in the graphic window is shifted by 1px (horizontally) and the last pixel of each line wrap around GW and appears at the start of the line.

Picture explains what I mean:

 

gw_wrapped_pixels.png

 

This problem doesn't depend on the size and position of the GW. It is not possible to eliminate it by address offset.

I use 800x480 24BPP display, but I've tested at 480x272 24 BPP display - same problem.

 

 

Here is my initialization of the LCDC, near standard code from Freescale examples:

 

void lcdc_init_screen()

{

    int * pointer32;

    int i;

    LCDC_MemMapPtr lcd;

 

    //Enable BL

    lwgpio_init(&lcd_backlight, LCD_BACKLIGHT, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE);

    lwgpio_set_functionality(&lcd_backlight, LWGPIO_MUX_A11_GPIO);

    lwgpio_set_value(&lcd_backlight, LWGPIO_VALUE_HIGH);

 

    //Reset LCD

    lwgpio_init(&lcd_reset, LCD_RESET, LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_NOCHANGE);

    lwgpio_set_functionality(&lcd_reset, LWGPIO_MUX_B16_GPIO);

    /* Attempt reset */

    lwgpio_set_value(&lcd_reset, LWGPIO_VALUE_LOW);

 

    _time_delay_ticks (10);

    /* Disable reset */

    lwgpio_set_value(&lcd_reset, LWGPIO_VALUE_HIGH);

 

    lcd = (LCDC_MemMapPtr) LCDC_BASE_PTR;

 

    // set LCD Screen Start Address

    lcd->LSSAR = FRAME_ADDR(0);

 

    // set LCD Size. The XMAX bitfield is the screen x-size/16.

    lcd->LSR = LCDC_LSR_XMAX( (SCREEN_XSIZE / 16) ) | LCDC_LSR_YMAX( SCREEN_YSIZE );

 

    // set LCD virtual page width

    lcd->LVPWR = LCDC_LVPWR_VPW (PAGE_XSIZE);

 

    // set LCD cursor positon & settings (turn off)

    lcd->LCPR = 0;

    lcd->LCWHB = 0;

 

    // set LCD panel configuration. Use endianess to work with TWR-LCD-RGB lines.

    lcd->LPCR =

    LCDC_LPCR_TFT_MASK      |       //TFT Screen

    LCDC_LPCR_COLOR_MASK    |       //Color

    LCDC_LPCR_BPIX(0x7)     |       //24 bpp

    LCDC_LPCR_CLKPOL_MASK    |        //falling edge

    LCDC_LPCR_FLMPOL_MASK   |       //first line marker active low

    LCDC_LPCR_LPPOL_MASK    |       //line pulse active low

    LCDC_LPCR_END_SEL_MASK  |       //Use big-endian mode (0xFFAA5500 means R=AA,G=55,B=00).  

    LCDC_LPCR_SWAP_SEL_MASK |       //Set so that the LCD data lines match up correctly with the TWR-LCD-RGB

    LCDC_LPCR_SCLKIDLE_MASK |       //Enalbe LSCLK when vsync is idle

    LCDC_LPCR_SCLKSEL_MASK  |       //Always enable clock

    LCDC_LPCR_PCD(0x4);             //Divide 150MHz PLL0 clock (default clock) by (4+1)=5 to get 30MHz clock

 

    // set LCD horizontal configuration based on panel data (Figure 3-3 in Seiko datasheet)

    lcd->LHCR =

        LCDC_LHCR_H_WIDTH(19)   |    //(19+1)=20 SCLK period for HSYNC activated

        LCDC_LHCR_H_WAIT_1(15)  |    //(15+1)=16 SCLK period between end of OE and beginning of HSYNC

        LCDC_LHCR_H_WAIT_2(23);     //(23+3)=26 SCLK periods between end of HSYNC and beginning of OE

 

    // set LCD vertical configuration based on panel data (Figure 3-3 in Seiko datasheet)

    lcd->LVCR =

        LCDC_LVCR_V_WIDTH(10)  |    //15 SCLK period for VSYNC activated

        LCDC_LVCR_V_WAIT_1(7) |    //22 SCLK period between end of OE and beginning of VSYNC

        LCDC_LVCR_V_WAIT_2(13);     //15 SCLK periods between end of VSYNC and beginning of OE

   

    // set the LCD panning offset (not used in 24bpp mode)

    lcd->LPOR = 0;

 

    // set LCD interrupt configuration register (interrupt on loading last data of frame from memory)

    lcd->LICR = 0;

 

    //Enable end of frame interrupts LCDC interrupts

    lcd->LIER =

    LCDC_LIER_EOF_EN_MASK;

    //LCDC_LIER_GW_EOF_EN_MASK;

 

    //Disable the graphic window. See the "color" and "fsl" demos for examples of

    //  using the graphic window feature

    lcd->LGWCR &=~LCDC_LGWCR_GWE_MASK;     

 

    lcd->LDCR &= ~LCDC_LDCR_TM_MASK;

    lcd->LDCR &= ~LCDC_LDCR_HM_MASK;

 

    lcd->LDCR |= LCDC_LDCR_TM(0x7D);

    lcd->LDCR |= LCDC_LDCR_HM(0x03);

 

    //Set background plane DMA to burst mode

    lcd->LDCR&=~LCDC_LDCR_BURST_MASK;

 

    lcd->LGWDCR &= ~LCDC_LGWDCR_GWTM_MASK;

    lcd->LGWDCR &= ~LCDC_LGWDCR_GWHM_MASK;

    lcd->LGWDCR |= LCDC_LGWDCR_GWTM(0x7D);

    lcd->LGWDCR |= LCDC_LGWDCR_GWHM(0x03);

 

    //Set graphic window DMA to burst mode

    lcd->LGWDCR&=~LCDC_LGWDCR_GWBT_MASK;

 

    lcd->LGWSAR = GW_START_ADDRESS(0);

 

    // set LCD graphic window size to be as big as the LCD display

    lcd->LGWSR =

        LCDC_LGWSR_GWW(GW_XSIZE/16) |

        LCDC_LGWSR_GWH(GW_YSIZE);

 

    //  set LCD graphic window virtual page width

    lcd->LGWVPWR = PAGE_XSIZE;

 

    //  set LCD graphic window panning offset

    lcd->LGWPOR = 0;

 

    //  set LCD graphic window position to start in the upper left corner

    lcd->LGWPR =

        LCDC_LGWPR_GWXP(0) |

        LCDC_LGWPR_GWYP(0);

 

    //  set LCD graphic window control

    lcd->LGWCR =

        LCDC_LGWCR_GWAV(0x00);    //| // alpha-transparent (0xFF means opaque)

        LCDC_LGWCR_GWE_MASK;       // enable */

     

    //set LCD cursor

    lcd->LCPR = 0; 

     

    lcd->LCWHB =

        LCDC_LCWHB_CH(26) |

        LCDC_LCWHB_CW(1)|

        LCDC_LCWHB_BD(20) |

        LCDC_LCWHB_BK_EN_MASK;

 

    lcd->LCCMR = 0;

 

    //Start LCDC

    SIM_MCR |= SIM_MCR_LCDSTART_MASK;

}

 

Thanks,

Slawek

Outcomes