LCD using AT91 Atmel driver ... every other line is gray

6 views
Skip to first unread message

JoRyTe

unread,
Oct 24, 2013, 9:05:57 PM10/24/13
to pico-S...@googlegroups.com
Hi group,

I have the Innolux 4.3" LCD available as an add-on for purchase with the board.

I have Android (2.3.4 Gingerbread, not that it matters) installed to the SD card, as described on the wiki, and am able to boot it just fine, LCD looks good.  I am able to play around with Android. I do this just to test and make sure the board is working and to familiarize myself with interfacing to it.My intended use for this board, however, is a custom embedded LCD-Touchscreen firmware, not an OS. 

So, I take bootstrap project from the wiki used to build BOOT.BIN and modify it by replacing main.c with the main.c from the Atmel-provided AT91SAM9G45-EK samples "basic-lcd-project-at91sam9m10-ek-gnu". I modify the main.c source to prepopulate the image buffers with a solid color instead of requiring the transfer of raw image files to DDR, which I am unable to do for various reasons.  I also copy over the necessary peripheral and driver sources from the project (also included in the AT91Lib from Atmel), modify the makefile to compile and link against the new libraries and build using the compile.sh script.  I take the resulting BOOT.BIN and replace the BOOT.BIN on the SD card.  I replace the SD card into the pico board and power it up.  Attached is a zip of my project, including the libraries and modified main.c.

I am able to see the basic lcd project firmware executing, with all of the DBGU output looking good in my putty terminal.  However, the LCD display does not show a solid color background but rather alternating horizontal lines of the color I have chosen and gray.  Actually, when my selected color is green I get alternating green and magenta, but if my selected color is red or blue I get alternating red/blue and gray.  I can't get the screen to display a solid color.  I have also tried using the draw.c/h source with no effect.  I have tried drawing diagonal lines and instead get a line of pixels down the left side of the screen and a row of pixels across the top of the screen, with the remaining screen alternating gray and black.  No matter what I draw into the pixel buffer, I only see it reflected on every-other line of the LCD, with the remaining lines being gray (usually).

Having stepped through the LCD initialization function, I can see the pin-striping doesn't appear on the screen until the LCD_Enable(0xC) function call is made.  Before that, the LCD screen is completely white (every row), having been initialized but not enabled.

I see this whether my start framework is the basic-lcd-project, the picopc bootstrap, or my own make project.  The LCD and board are known good because I can switch back to the stock BOOT.BIN at any time and see Android boot nicely, display always looks perfect.

Any ideas on what the problem is?  My best guess is a misconfiguration in the device.h file, but I don't know enough about LCDs to determine what parameter might be wrong or what variation between the pico board and the AT91SAM9G45-EKES or between the Innolux LCD and the Toshiba LCD that comes with the Atmel dev board might affect this.

Any ideas or anyone able to recreate this on their boards?



Thanks,
JoRyTe


bootstrap-sdcard.zip

Nicu Pavel

unread,
Oct 25, 2013, 3:10:00 AM10/25/13
to pico-sam9g45
Hi,


Probably the LCD is not initialized configure correctly.
in functions atmel_lcdfb_check_var(), atmel_lcdfb_set_par_init()


Regards,
Nicu Pavel
 

JoRyTe

unread,
Oct 25, 2013, 9:12:11 AM10/25/13
to pico-S...@googlegroups.com

Thanks for the reply Nicu.  Looks like good stuff in those documents.  It's gonna take me some time to sort through the code and match up your linux-based api and data structures with the raw firmware ones used in my driver.  In the mean time, here are the initialization-relevant portions of my code:

One interesting thing is the mention of non-interlaced mode in your driver, however, I don't see any mention of interlacing mentioned in my driver.  This certainly seems like it could be an interlacing issue since it is every-other line.  However, the Atmel-provided API doesn't even provide a means of specifying interlacing that I have found.

There is this nugget:
LCD_SetScanMode(AT91C_LCDC_SCANMOD_SINGLESCAN);


Thanks,
JoRyTe




from main.c:
//------------------------------------------------------------------------------
/// Initializes the LCD controller with the board parameters.
//------------------------------------------------------------------------------
void InitializeLcd()
{
   
// Enable peripheral clock
    AT91C_BASE_PMC
->PMC_PCER = 1 << AT91C_ID_LCDC;

#if defined(at91sam9g10)||defined(at91sam9261)
    AT91C_BASE_PMC
->PMC_SCER = AT91C_PMC_HCK1;
#endif

   
// Disable the LCD and the DMA
    LCD_DisableDma
();
    LCD_Disable
(0);

   
// Configure the LCD controller
    LCD_SetPixelClock
(BOARD_MCK, BOARD_LCD_PIXELCLOCK);
    LCD_SetDisplayType
(BOARD_LCD_DISPLAYTYPE);
    LCD_SetScanMode
(AT91C_LCDC_SCANMOD_SINGLESCAN);
    LCD_SetBitsPerPixel
(BOARD_LCD_BPP);
    LCD_SetPolarities
(BOARD_LCD_POLARITY_INVVD,
                      BOARD_LCD_POLARITY_INVFRAME
,
                      BOARD_LCD_POLARITY_INVLINE
,
                      BOARD_LCD_POLARITY_INVCLK
,
                      BOARD_LCD_POLARITY_INVDVAL
);
    LCD_SetClockMode
(BOARD_LCD_CLOCKMODE);
    LCD_SetMemoryFormat
((unsigned int) AT91C_LCDC_MEMOR_LITTLEIND);
    LCD_SetSize
(BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT);
   
// Configure timings
    LCD_SetVerticalTimings
(BOARD_LCD_TIMING_VFP,
                           BOARD_LCD_TIMING_VBP
,
                           BOARD_LCD_TIMING_VPW
,
                           BOARD_LCD_TIMING_VHDLY
);
    LCD_SetHorizontalTimings
(BOARD_LCD_TIMING_HBP,
                             BOARD_LCD_TIMING_HPW
,
                             BOARD_LCD_TIMING_HFP
);

   
// Configure contrast (TODO functions)
    LCD_SetContrastPrescaler
(AT91C_LCDC_PS_NOTDIVIDED);
    LCD_SetContrastPolarity
(AT91C_LCDC_POL_POSITIVEPULSE);
    LCD_SetContrastValue
(0x80);
    LCD_EnableContrast
();

   
// Configure DMA
    LCD_SetFrameSize
(BOARD_LCD_FRAMESIZE);
    LCD_SetBurstLength
(4);

   
// Set frame buffer
    LCD_SetFrameBufferAddress
(images[0]);

   
// Enable DMA and LCD
    LCD_EnableDma
();
    LCD_Enable
(0x0C);
}


from board.h:
/// LCD pin list.
#define PINS_LCD    \
   
{0x7FFFFFFD, AT91C_BASE_PIOE, AT91C_ID_PIOD_E, PIO_PERIPH_A, PIO_DEFAULT}
/// Board is wired in BGR 565.
#define BOARD_LCD_BGR565
/// Display width in pixels.
#define BOARD_LCD_WIDTH             480
/// Display height in pixels.
#define BOARD_LCD_HEIGHT            272
/// Display resolution in bits per pixel (bpp).
#define BOARD_LCD_BPP               AT91C_LCDC_PIXELSIZE_TWENTYFOURBITSPERPIXEL
/// Display interface width in bits.
#define BOARD_LCD_IFWIDTH           24
/// Frame size in pixels (height * width * bpp).
#define BOARD_LCD_FRAMESIZE_PIXELS  (BOARD_LCD_WIDTH * BOARD_LCD_HEIGHT * 24)
/// Frame size in words (height * width * bpp / 32)
#define BOARD_LCD_FRAMESIZE         (BOARD_LCD_FRAMESIZE_PIXELS / 32)
/// Frame rate in Hz.
#define BOARD_LCD_FRAMERATE         60
/// Pixel clock rate in Hz (frameSize * frameRate / interfaceWidth).
#define BOARD_LCD_PIXELCLOCK        (BOARD_LCD_FRAMESIZE_PIXELS * BOARD_LCD_FRAMERATE / BOARD_LCD_IFWIDTH)
/// LCD display type.
#define BOARD_LCD_DISPLAYTYPE       AT91C_LCDC_DISTYPE_TFT
/// LCDC polarity.
#define BOARD_LCD_POLARITY_INVVD    AT91C_LCDC_INVVD_NORMALPOL
/// LCDVSYNC polarity.
#define BOARD_LCD_POLARITY_INVFRAME AT91C_LCDC_INVFRAME_INVERTEDPOL
/// LCDHSYNC polarity.
#define BOARD_LCD_POLARITY_INVLINE  AT91C_LCDC_INVLINE_INVERTEDPOL
/// LCDDOTCLK polarity.
#define BOARD_LCD_POLARITY_INVCLK   AT91C_LCDC_INVCLK_NORMALPOL
/// LCDDEN polarity.
#define BOARD_LCD_POLARITY_INVDVAL  AT91C_LCDC_INVDVAL_NORMALPOL
/// Pixel clock mode.
#define BOARD_LCD_CLOCKMODE         AT91C_LCDC_CLKMOD_ALWAYSACTIVE
/// Vertical front porch in number of lines.
#define BOARD_LCD_TIMING_VFP        4
/// Vertical back porch in number of lines.
#define BOARD_LCD_TIMING_VBP        4
/// Vertical pulse width in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_VPW        4
/// Number of cycles between VSYNC edge and HSYNC rising edge.
#define BOARD_LCD_TIMING_VHDLY      2
/// Horizontal front porch in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HFP        5
/// Horizontal back porch in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HBP        5
/// Horizontal pulse width in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HPW        5


from AT91SAM9G45.h:

// *****************************************************************************
//              SOFTWARE API DEFINITION  FOR LCD Controller
// *****************************************************************************
#ifndef __ASSEMBLY__
typedef struct _AT91S_LCDC {
        AT91_REG         LCDC_BA1
;      // DMA Base Address Register 1
        AT91_REG         LCDC_BA2
;      // DMA Base Address Register 2
        AT91_REG         LCDC_FRMP1
;    // DMA Frame Pointer Register 1
        AT91_REG         LCDC_FRMP2
;    // DMA Frame Pointer Register 2
        AT91_REG         LCDC_FRMA1
;    // DMA Frame Address Register 1
        AT91_REG         LCDC_FRMA2
;    // DMA Frame Address Register 2
        AT91_REG         LCDC_FRMCFG
;   // DMA Frame Configuration Register
        AT91_REG         LCDC_DMACON
;   // DMA Control Register
        AT91_REG         LCDC_DMA2DCFG
;         // DMA 2D addressing configuration
        AT91_REG        
Reserved0[503];        //
        AT91_REG         LCDC_LCDCON1
;  // LCD Control 1 Register
        AT91_REG         LCDC_LCDCON2
;  // LCD Control 2 Register
        AT91_REG         LCDC_TIM1
;     // LCD Timing Config 1 Register
        AT91_REG         LCDC_TIM2
;     // LCD Timing Config 2 Register
        AT91_REG         LCDC_LCDFRCFG
;         // LCD Frame Config Register
        AT91_REG         LCDC_FIFO
;     // LCD FIFO Register
        AT91_REG         LCDC_MVAL
;     // LCD Mode Toggle Rate Value Register
        AT91_REG         LCDC_DP1_2
;    // Dithering Pattern DP1_2 Register
        AT91_REG         LCDC_DP4_7
;    // Dithering Pattern DP4_7 Register
        AT91_REG         LCDC_DP3_5
;    // Dithering Pattern DP3_5 Register
        AT91_REG         LCDC_DP2_3
;    // Dithering Pattern DP2_3 Register
        AT91_REG         LCDC_DP5_7
;    // Dithering Pattern DP5_7 Register
        AT91_REG         LCDC_DP3_4
;    // Dithering Pattern DP3_4 Register
        AT91_REG         LCDC_DP4_5
;    // Dithering Pattern DP4_5 Register
        AT91_REG         LCDC_DP6_7
;    // Dithering Pattern DP6_7 Register
        AT91_REG         LCDC_PWRCON
;   // Power Control Register
        AT91_REG         LCDC_CTRSTCON
;         // Contrast Control Register
        AT91_REG         LCDC_CTRSTVAL
;         // Contrast Value Register
        AT91_REG         LCDC_IER
;      // Interrupt Enable Register
        AT91_REG         LCDC_IDR
;      // Interrupt Disable Register
        AT91_REG         LCDC_IMR
;      // Interrupt Mask Register
        AT91_REG         LCDC_ISR
;      // Interrupt Enable Register
        AT91_REG         LCDC_ICR
;      // Interrupt Clear Register
        AT91_REG         LCDC_GPR
;      // General Purpose Register
        AT91_REG         LCDC_ITR
;      // Interrupts Test Register
        AT91_REG         LCDC_IRR
;      // Interrupts Raw Status Register
        AT91_REG        
Reserved1[230];        //
        AT91_REG         LCDC_LUT_ENTRY
[256];   // LUT Entries Register
} AT91S_LCDC, *AT91PS_LCDC;
#else
#define LCDC_BA1        (AT91_CAST(AT91_REG *)  0x00000000) // (LCDC_BA1) DMA Base Address Register 1
#define LCDC_BA2        (AT91_CAST(AT91_REG *)  0x00000004) // (LCDC_BA2) DMA Base Address Register 2
#define LCDC_FRMP1      (AT91_CAST(AT91_REG *)  0x00000008) // (LCDC_FRMP1) DMA Frame Pointer Register 1
#define LCDC_FRMP2      (AT91_CAST(AT91_REG *)  0x0000000C) // (LCDC_FRMP2) DMA Frame Pointer Register 2
#define LCDC_FRMA1      (AT91_CAST(AT91_REG *)  0x00000010) // (LCDC_FRMA1) DMA Frame Address Register 1
#define LCDC_FRMA2      (AT91_CAST(AT91_REG *)  0x00000014) // (LCDC_FRMA2) DMA Frame Address Register 2
#define LCDC_FRMCFG     (AT91_CAST(AT91_REG *)  0x00000018) // (LCDC_FRMCFG) DMA Frame Configuration Register
#define LCDC_DMACON     (AT91_CAST(AT91_REG *)  0x0000001C) // (LCDC_DMACON) DMA Control Register
#define LCDC_DMA2DCFG   (AT91_CAST(AT91_REG *)  0x00000020) // (LCDC_DMA2DCFG) DMA 2D addressing configuration
#define LCDC_LCDCON1    (AT91_CAST(AT91_REG *)  0x00000800) // (LCDC_LCDCON1) LCD Control 1 Register
#define LCDC_LCDCON2    (AT91_CAST(AT91_REG *)  0x00000804) // (LCDC_LCDCON2) LCD Control 2 Register
#define LCDC_TIM1       (AT91_CAST(AT91_REG *)  0x00000808) // (LCDC_TIM1) LCD Timing Config 1 Register
#define LCDC_TIM2       (AT91_CAST(AT91_REG *)  0x0000080C) // (LCDC_TIM2) LCD Timing Config 2 Register
#define LCDC_LCDFRCFG   (AT91_CAST(AT91_REG *)  0x00000810) // (LCDC_LCDFRCFG) LCD Frame Config Register
#define LCDC_FIFO       (AT91_CAST(AT91_REG *)  0x00000814) // (LCDC_FIFO) LCD FIFO Register
#define LCDC_MVAL       (AT91_CAST(AT91_REG *)  0x00000818) // (LCDC_MVAL) LCD Mode Toggle Rate Value Register
#define LCDC_DP1_2      (AT91_CAST(AT91_REG *)  0x0000081C) // (LCDC_DP1_2) Dithering Pattern DP1_2 Register
#define LCDC_DP4_7      (AT91_CAST(AT91_REG *)  0x00000820) // (LCDC_DP4_7) Dithering Pattern DP4_7 Register
#define LCDC_DP3_5      (AT91_CAST(AT91_REG *)  0x00000824) // (LCDC_DP3_5) Dithering Pattern DP3_5 Register
#define LCDC_DP2_3      (AT91_CAST(AT91_REG *)  0x00000828) // (LCDC_DP2_3) Dithering Pattern DP2_3 Register
#define LCDC_DP5_7      (AT91_CAST(AT91_REG *)  0x0000082C) // (LCDC_DP5_7) Dithering Pattern DP5_7 Register
#define LCDC_DP3_4      (AT91_CAST(AT91_REG *)  0x00000830) // (LCDC_DP3_4) Dithering Pattern DP3_4 Register
#define LCDC_DP4_5      (AT91_CAST(AT91_REG *)  0x00000834) // (LCDC_DP4_5) Dithering Pattern DP4_5 Register
#define LCDC_DP6_7      (AT91_CAST(AT91_REG *)  0x00000838) // (LCDC_DP6_7) Dithering Pattern DP6_7 Register
#define LCDC_PWRCON     (AT91_CAST(AT91_REG *)  0x0000083C) // (LCDC_PWRCON) Power Control Register
#define LCDC_CTRSTCON   (AT91_CAST(AT91_REG *)  0x00000840) // (LCDC_CTRSTCON) Contrast Control Register
#define LCDC_CTRSTVAL   (AT91_CAST(AT91_REG *)  0x00000844) // (LCDC_CTRSTVAL) Contrast Value Register
#define LCDC_IER        (AT91_CAST(AT91_REG *)  0x00000848) // (LCDC_IER) Interrupt Enable Register
#define LCDC_IDR        (AT91_CAST(AT91_REG *)  0x0000084C) // (LCDC_IDR) Interrupt Disable Register
#define LCDC_IMR        (AT91_CAST(AT91_REG *)  0x00000850) // (LCDC_IMR) Interrupt Mask Register
#define LCDC_ISR        (AT91_CAST(AT91_REG *)  0x00000854) // (LCDC_ISR) Interrupt Enable Register
#define LCDC_ICR        (AT91_CAST(AT91_REG *)  0x00000858) // (LCDC_ICR) Interrupt Clear Register
#define LCDC_GPR        (AT91_CAST(AT91_REG *)  0x0000085C) // (LCDC_GPR) General Purpose Register
#define LCDC_ITR        (AT91_CAST(AT91_REG *)  0x00000860) // (LCDC_ITR) Interrupts Test Register
#define LCDC_IRR        (AT91_CAST(AT91_REG *)  0x00000864) // (LCDC_IRR) Interrupts Raw Status Register
#define LCDC_LUT_ENTRY  (AT91_CAST(AT91_REG *)  0x00000C00) // (LCDC_LUT_ENTRY) LUT Entries Register

#endif
// -------- LCDC_FRMP1 : (LCDC Offset: 0x8) DMA Frame Pointer 1 Register --------
#define AT91C_LCDC_FRMPT1     (0x3FFFFF <<  0) // (LCDC) Frame Pointer Address 1
// -------- LCDC_FRMP2 : (LCDC Offset: 0xc) DMA Frame Pointer 2 Register --------
#define AT91C_LCDC_FRMPT2     (0x1FFFFF <<  0) // (LCDC) Frame Pointer Address 2
// -------- LCDC_FRMCFG : (LCDC Offset: 0x18) DMA Frame Config Register --------
#define AT91C_LCDC_FRSIZE     (0x7FFFFF <<  0) // (LCDC) FRAME SIZE
#define AT91C_LCDC_BLENGTH    (0x7F << 24) // (LCDC) BURST LENGTH
// -------- LCDC_DMACON : (LCDC Offset: 0x1c) DMA Control Register --------
#define AT91C_LCDC_DMAEN      (0x1 <<  0) // (LCDC) DAM Enable
#define AT91C_LCDC_DMARST     (0x1 <<  1) // (LCDC) DMA Reset (WO)
#define AT91C_LCDC_DMABUSY    (0x1 <<  2) // (LCDC) DMA Reset (WO)
#define AT91C_LCDC_DMAUPDT    (0x1 <<  3) // (LCDC) DMA Configuration Update
#define AT91C_LCDC_DMA2DEN    (0x1 <<  4) // (LCDC) 2D Addressing Enable
// -------- LCDC_DMA2DCFG : (LCDC Offset: 0x20) DMA 2D addressing configuration Register --------
#define AT91C_LCDC_ADDRINC    (0xFFFF <<  0) // (LCDC) Number of 32b words that the DMA must jump when going to the next line
#define AT91C_LCDC_PIXELOFF   (0x1F << 24) // (LCDC) Offset (in bits) of the first pixel of the screen in the memory word which contain it
// -------- LCDC_LCDCON1 : (LCDC Offset: 0x800) LCD Control 1 Register --------
#define AT91C_LCDC_BYPASS     (0x1 <<  0) // (LCDC) Bypass lcd_pccklk divider
#define AT91C_LCDC_CLKVAL     (0x1FF << 12) // (LCDC) 9-bit Divider for pixel clock frequency
#define AT91C_LCDC_LINCNT     (0x7FF << 21) // (LCDC) Line Counter (RO)
// -------- LCDC_LCDCON2 : (LCDC Offset: 0x804) LCD Control 2 Register --------
#define AT91C_LCDC_DISTYPE    (0x3 <<  0) // (LCDC) Display Type
#define         AT91C_LCDC_DISTYPE_STNMONO              (0x0) // (LCDC) STN Mono
#define         AT91C_LCDC_DISTYPE_STNCOLOR             (0x1) // (LCDC) STN Color
#define         AT91C_LCDC_DISTYPE_TFT                  (0x2) // (LCDC) TFT
#define AT91C_LCDC_SCANMOD    (0x1 <<  2) // (LCDC) Scan Mode
#define         AT91C_LCDC_SCANMOD_SINGLESCAN           (0x0 <<  2) // (LCDC) Single Scan
#define         AT91C_LCDC_SCANMOD_DUALSCAN             (0x1 <<  2) // (LCDC) Dual Scan
#define AT91C_LCDC_IFWIDTH    (0x3 <<  3) // (LCDC) Interface Width
#define         AT91C_LCDC_IFWIDTH_FOURBITSWIDTH        (0x0 <<  3) // (LCDC) 4 Bits
#define         AT91C_LCDC_IFWIDTH_EIGTHBITSWIDTH       (0x1 <<  3) // (LCDC) 8 Bits
#define         AT91C_LCDC_IFWIDTH_SIXTEENBITSWIDTH     (0x2 <<  3) // (LCDC) 16 Bits
#define AT91C_LCDC_PIXELSIZE  (0x7 <<  5) // (LCDC) Bits per pixel
#define         AT91C_LCDC_PIXELSIZE_ONEBITSPERPIXEL      (0x0 <<  5) // (LCDC) 1 Bits
#define         AT91C_LCDC_PIXELSIZE_TWOBITSPERPIXEL      (0x1 <<  5) // (LCDC) 2 Bits
#define         AT91C_LCDC_PIXELSIZE_FOURBITSPERPIXEL     (0x2 <<  5) // (LCDC) 4 Bits
#define         AT91C_LCDC_PIXELSIZE_EIGTHBITSPERPIXEL    (0x3 <<  5) // (LCDC) 8 Bits
#define         AT91C_LCDC_PIXELSIZE_SIXTEENBITSPERPIXEL  (0x4 <<  5) // (LCDC) 16 Bits
#define         AT91C_LCDC_PIXELSIZE_TWENTYFOURBITSPERPIXEL (0x5 <<  5) // (LCDC) 24 Bits
#define AT91C_LCDC_INVVD      (0x1 <<  8) // (LCDC) lcd datas polarity
#define         AT91C_LCDC_INVVD_NORMALPOL            (0x0 <<  8) // (LCDC) Normal Polarity
#define         AT91C_LCDC_INVVD_INVERTEDPOL          (0x1 <<  8) // (LCDC) Inverted Polarity
#define AT91C_LCDC_INVFRAME   (0x1 <<  9) // (LCDC) lcd vsync polarity
#define         AT91C_LCDC_INVFRAME_NORMALPOL            (0x0 <<  9) // (LCDC) Normal Polarity
#define         AT91C_LCDC_INVFRAME_INVERTEDPOL          (0x1 <<  9) // (LCDC) Inverted Polarity
#define AT91C_LCDC_INVLINE    (0x1 << 10) // (LCDC) lcd hsync polarity
#define         AT91C_LCDC_INVLINE_NORMALPOL            (0x0 << 10) // (LCDC) Normal Polarity
#define         AT91C_LCDC_INVLINE_INVERTEDPOL          (0x1 << 10) // (LCDC) Inverted Polarity
#define AT91C_LCDC_INVCLK     (0x1 << 11) // (LCDC) lcd pclk polarity
#define         AT91C_LCDC_INVCLK_NORMALPOL            (0x0 << 11) // (LCDC) Normal Polarity
#define         AT91C_LCDC_INVCLK_INVERTEDPOL          (0x1 << 11) // (LCDC) Inverted Polarity
#define AT91C_LCDC_INVDVAL    (0x1 << 12) // (LCDC) lcd dval polarity
#define         AT91C_LCDC_INVDVAL_NORMALPOL            (0x0 << 12) // (LCDC) Normal Polarity
#define         AT91C_LCDC_INVDVAL_INVERTEDPOL          (0x1 << 12) // (LCDC) Inverted Polarity
#define AT91C_LCDC_CLKMOD     (0x1 << 15) // (LCDC) lcd pclk Mode
#define         AT91C_LCDC_CLKMOD_ACTIVEONLYDISP       (0x0 << 15) // (LCDC) Active during display period
#define         AT91C_LCDC_CLKMOD_ALWAYSACTIVE         (0x1 << 15) // (LCDC) Always Active
#define AT91C_LCDC_MEMOR      (0x3 << 30) // (LCDC) Memory Ordering Format
#define         AT91C_LCDC_MEMOR_BIGIND               (0x0 << 30) // (LCDC) Big Endian
#define         AT91C_LCDC_MEMOR_LITTLEIND            (0x2 << 30) // (LCDC) Little Endian
// -------- LCDC_TIM1 : (LCDC Offset: 0x808) LCDC Timing Config 1 Register --------
#define AT91C_LCDC_VFP        (0xFF <<  0) // (LCDC) Vertical Front Porch
#define AT91C_LCDC_VBP        (0xFF <<  8) // (LCDC) Vertical Back Porch
#define AT91C_LCDC_VPW        (0x3F << 16) // (LCDC) Vertical Synchronization Pulse Width
#define AT91C_LCDC_VHDLY      (0xF << 24) // (LCDC) Vertical to Horizontal Delay
// -------- LCDC_TIM2 : (LCDC Offset: 0x80c) LCDC Timing Config 2 Register --------
#define AT91C_LCDC_HBP        (0xFF <<  0) // (LCDC) Horizontal Back Porch
#define AT91C_LCDC_HPW        (0x3F <<  8) // (LCDC) Horizontal Synchronization Pulse Width
#define AT91C_LCDC_HFP        (0x7FF << 21) // (LCDC) Horizontal Front Porch
// -------- LCDC_LCDFRCFG : (LCDC Offset: 0x810) LCD Frame Config Register --------
#define AT91C_LCDC_LINEVAL    (0x7FF <<  0) // (LCDC) Vertical Size of LCD Module
#define AT91C_LCDC_HOZVAL     (0x7FF << 21) // (LCDC) Horizontal Size of LCD Module
// -------- LCDC_FIFO : (LCDC Offset: 0x814) LCD FIFO Register --------
#define AT91C_LCDC_FIFOTH     (0xFFFF <<  0) // (LCDC) FIFO Threshold
// -------- LCDC_MVAL : (LCDC Offset: 0x818) LCD Mode Toggle Rate Value Register --------
#define AT91C_LCDC_MVALUE     (0xFF <<  0) // (LCDC) Toggle Rate Value
#define AT91C_LCDC_MMODE      (0x1 << 31) // (LCDC) Toggle Rate Sel
#define         AT91C_LCDC_MMODE_EACHFRAME            (0x0 << 31) // (LCDC) Each Frame
#define         AT91C_LCDC_MMODE_MVALDEFINED          (0x1 << 31) // (LCDC) Defined by MVAL
// -------- LCDC_DP1_2 : (LCDC Offset: 0x81c) Dithering Pattern 1/2 --------
#define AT91C_LCDC_DP1_2_FIELD (0xFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP4_7 : (LCDC Offset: 0x820) Dithering Pattern 4/7 --------
#define AT91C_LCDC_DP4_7_FIELD (0xFFFFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP3_5 : (LCDC Offset: 0x824) Dithering Pattern 3/5 --------
#define AT91C_LCDC_DP3_5_FIELD (0xFFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP2_3 : (LCDC Offset: 0x828) Dithering Pattern 2/3 --------
#define AT91C_LCDC_DP2_3_FIELD (0xFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP5_7 : (LCDC Offset: 0x82c) Dithering Pattern 5/7 --------
#define AT91C_LCDC_DP5_7_FIELD (0xFFFFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP3_4 : (LCDC Offset: 0x830) Dithering Pattern 3/4 --------
#define AT91C_LCDC_DP3_4_FIELD (0xFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP4_5 : (LCDC Offset: 0x834) Dithering Pattern 4/5 --------
#define AT91C_LCDC_DP4_5_FIELD (0xFFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_DP6_7 : (LCDC Offset: 0x838) Dithering Pattern 6/7 --------
#define AT91C_LCDC_DP6_7_FIELD (0xFFFFFFF <<  0) // (LCDC) Ratio
// -------- LCDC_PWRCON : (LCDC Offset: 0x83c) LCDC Power Control Register --------
#define AT91C_LCDC_PWR        (0x1 <<  0) // (LCDC) LCD Module Power Control
#define AT91C_LCDC_GUARDT     (0x7F <<  1) // (LCDC) Delay in Frame Period
#define AT91C_LCDC_BUSY       (0x1 << 31) // (LCDC) Read Only : 1 indicates that LCDC is busy
#define         AT91C_LCDC_BUSY_LCDNOTBUSY           (0x0 << 31) // (LCDC) LCD is Not Busy
#define         AT91C_LCDC_BUSY_LCDBUSY              (0x1 << 31) // (LCDC) LCD is Busy
// -------- LCDC_CTRSTCON : (LCDC Offset: 0x840) LCDC Contrast Control Register --------
#define AT91C_LCDC_PS         (0x3 <<  0) // (LCDC) LCD Contrast Counter Prescaler
#define         AT91C_LCDC_PS_NOTDIVIDED           (0x0) // (LCDC) Counter Freq is System Freq.
#define         AT91C_LCDC_PS_DIVIDEDBYTWO         (0x1) // (LCDC) Counter Freq is System Freq divided by 2.
#define         AT91C_LCDC_PS_DIVIDEDBYFOUR        (0x2) // (LCDC) Counter Freq is System Freq divided by 4.
#define         AT91C_LCDC_PS_DIVIDEDBYEIGHT       (0x3) // (LCDC) Counter Freq is System Freq divided by 8.
#define AT91C_LCDC_POL        (0x1 <<  2) // (LCDC) Polarity of output Pulse
#define         AT91C_LCDC_POL_NEGATIVEPULSE        (0x0 <<  2) // (LCDC) Negative Pulse
#define         AT91C_LCDC_POL_POSITIVEPULSE        (0x1 <<  2) // (LCDC) Positive Pulse
#define AT91C_LCDC_ENA        (0x1 <<  3) // (LCDC) PWM generator Control
#define         AT91C_LCDC_ENA_PWMGEMDISABLED       (0x0 <<  3) // (LCDC) PWM Generator Disabled
#define         AT91C_LCDC_ENA_PWMGEMENABLED        (0x1 <<  3) // (LCDC) PWM Generator Disabled
// -------- LCDC_CTRSTVAL : (LCDC Offset: 0x844) Contrast Value Register --------
#define AT91C_LCDC_CVAL       (0xFF <<  0) // (LCDC) PWM Compare Value
// -------- LCDC_IER : (LCDC Offset: 0x848) LCDC Interrupt Enable Register --------
#define AT91C_LCDC_LNI        (0x1 <<  0) // (LCDC) Line Interrupt
#define AT91C_LCDC_LSTLNI     (0x1 <<  1) // (LCDC) Last Line Interrupt
#define AT91C_LCDC_EOFI       (0x1 <<  2) // (LCDC) End Of Frame Interrupt
#define AT91C_LCDC_UFLWI      (0x1 <<  4) // (LCDC) FIFO Underflow Interrupt
#define AT91C_LCDC_OWRI       (0x1 <<  5) // (LCDC) Over Write Interrupt
#define AT91C_LCDC_MERI       (0x1 <<  6) // (LCDC) Memory Error  Interrupt
// -------- LCDC_IDR : (LCDC Offset: 0x84c) LCDC Interrupt Disable Register --------
// -------- LCDC_IMR : (LCDC Offset: 0x850) LCDC Interrupt Mask Register --------
// -------- LCDC_ISR : (LCDC Offset: 0x854) LCDC Interrupt Status Register --------
// -------- LCDC_ICR : (LCDC Offset: 0x858) LCDC Interrupt Clear Register --------
// -------- LCDC_GPR : (LCDC Offset: 0x85c) LCDC General Purpose Register --------
#define AT91C_LCDC_GPRBUS     (0xFF <<  0) // (LCDC) 8 bits available
// -------- LCDC_ITR : (LCDC Offset: 0x860) Interrupts Test Register --------
// -------- LCDC_IRR : (LCDC Offset: 0x864) Interrupts Raw Status Register --------


 

JoRyTe

unread,
Oct 25, 2013, 9:17:48 AM10/25/13
to pico-S...@googlegroups.com

Sorry, that last one got away from me too soon.  I meant to finish:


There is this nugget:
  LCD_SetScanMode(AT91C_LCDC_SCANMOD_SINGLESCAN);

I have tried using the AT91C_LCDC_SCANMOD_DUALSCAN parameter, thinking it might change from non-interlaced to interlaced or vice versa, but when I do I only get the alternating gray and black lines only, no vestige whatsoever of my image buffer, no matter what data I put in it.


JoRyTe

JoRyTe

unread,
Oct 25, 2013, 6:30:36 PM10/25/13
to pico-S...@googlegroups.com

The timings seemed to be the issue.  In the board.h file, I changed the following values to match what was in the board-picosam9g45.c (from line 207) file and now I get complete screen coverage of the image I construct:


/// Vertical front porch in number of lines.
#define BOARD_LCD_TIMING_VFP        2

/// Vertical back porch in number of lines.
#define BOARD_LCD_TIMING_VBP        2

/// Vertical pulse width in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_VPW        10

/// Number of cycles between VSYNC edge and HSYNC rising edge.
#define BOARD_LCD_TIMING_VHDLY      2
/// Horizontal front porch in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HFP        2

/// Horizontal back porch in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HBP        2

/// Horizontal pulse width in LCDDOTCLK cycles.
#define BOARD_LCD_TIMING_HPW        41

One final question, how are these timings determined, in the event that an LCD screen is swapped out? Is it the specific value that is determined or the range?  Are they parameters of the LCD screen that comes from its datasheet?

Thanks Nicu for the help!
JoRyTe

Nicu Pavel

unread,
Oct 26, 2013, 4:56:54 AM10/26/13
to pico-sam9g45
Hi,


On Sat, Oct 26, 2013 at 1:30 AM, JoRyTe <jor...@gmail.com> wrote:

The timings seemed to be the issue.  In the board.h file, I changed the following values to match what was in the board-picosam9g45.c (from line 207) file and now I get complete screen coverage of the image I construct:

[...]
One final question, how are these timings determined, in the event that an LCD screen is swapped out? Is it the specific value that is determined or the range?  Are they parameters of the LCD screen that comes from its datasheet?

Thanks Nicu for the help!

Take a look here how to translate values from a LCD datasheet:

Nicu 

JoRyTe

--
You received this message because you are subscribed to the Google Groups "pico-SAM9G45 Mini-Box.com ARM embedded system board" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pico-SAM9G45...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

JoRyTe

unread,
Oct 26, 2013, 9:30:04 AM10/26/13
to pico-S...@googlegroups.com
Great, thanks!  After all the time I've spent looking over the wiki, I don't know how I missed that page.  You've been helpful.

JoRyTe
Reply all
Reply to author
Forward
0 new messages