[讨论] 讨论TivaWare2.0版新增的LCD模块的使用方法!

平湖秋月   2014-1-5 17:17 楼主
坛友们慢慢讨论TI新添加的LCD控制器用法!!! 本帖最后由 平湖秋月 于 2014-1-7 14:11 编辑
  • 液晶控制器.JPG

回复评论 (18)

19.1 Introduction--介绍 The LCD Controller allows a variety of different character and graphic displays to be connected to and driven by the microcontroller. The LCD module contains two independent controllers, one supporting LCD Interface Display Driver (LIDD) mode command and data transactions to character displays or those containing an integrated controller with a packet-based interface, and the other driving clock, syncs and data suitable for RGB raster displays. Up to two simultaneous LIDD displays may be driven or a single RGB raster mode display. The LCD API provides functions to configure the interface type and timing for the attached display or displays. For LIDD mode displays, functions allow an application to send commands or data to the display or read back status or data. For raster displays, functions allow the pixel clock, HSYNC, VSYNC and ACTIVE timings to be set. Additional functions allow the frame buffer memory to be configured and the color palette to be set. This driver is contained in driverlib/lcd.c, with driverlib/lcd.h containing the API declarations for use by applications. 本帖最后由 平湖秋月 于 2014-1-6 13:24 编辑
点赞  2014-1-5 17:22
19.2.2 LCD Interface Display Driver (LIDD) ModeLCD接口显示驱动模式 The LIDD mode controller allows connection of displays via a synchronous or asynchronous interface using Chip Select (CS), Write Enable (WE), Output Enable (OE) and Address Latch Enable (ALE) signals along with a parallel data bus of 8 to 16 bits. Several different bus signaling modes are supported to allow connection of devices making use of Hitachi, Motorola or Intel bus conventions. For timing diagrams showing the operation of each of these modes, please consult the datasheet for your particular Tiva part. LIDD mode would typically be used with displays where updates are made via a packet-based command and data protocol rather than by direct access to a local frame buffer. These will generally be lower resolution RGB panels or character-mode displays. Interface signaling, timing and basic mode are set using three API functions. To select LIDD mode, LCDModeSet() is called with the ui8Mode parameter set to LCD_MODE_LIDD and the desired bit clock rate. LCDIDDConfigSet() is then called to set the basic operating mode of the LIDD interface (synchronous or asynchronous Motorola or Intel mode, or asynchronous Hitachi mode) and configure the polarities of the various interface control signals. Finally LCDIDDTimingSet() is called to set the timings associated with the interface strobes. When using the asynchronous Intel or Motorola interface modes, two independent chip select (CS) signals are available and timings may be set for these individually allowing two different LIDD panels to be attached simultaneously. Data may be transfered to or from the panel either one item (8-bit byte or 16-bit word depending upon the panel) at a time or in blocks using DMA. In basic operation, the API provides two sets of functions which allow reading and writing. The choice of function is dictated by the specification of the display in use and the hardware interface it uses. Functions LCDIDDDataRead(), LCDIDDDataWrite(), LCDIDDCommandWrite() and LCDIDDStatusRead() can be used with panels which support a Data/Control (DC) signal to control command or data accesses. Command writes and status reads are performed with the DC signal (on the ALE pin) active whereas data operations occur with the DC signal inactive. For displays using an external address latch and configured in one of the Intel or Motorola modes, LCDIDDIndexedRead() and LCDIDDIndexedWrite() may be used to read or write indexed registers in the display. To transfer large blocks of data to the display, DMA may be used via the LCDIDDDMAWrite() function. This function enables the DMA engine in the LCD controller before transfering the required block of data to the display. The DMA engine transfers data 16 bits at a time so data must be padded if a display with an 8 bit interface is used. The completion of a DMA transfer is indicated via the LCD_INT_DMA_DONE interrupt. Care must be taken when mixing DMA and non-DMA accesses to the display. The application is responsible for ensuring that any previous DMA operation has completed before another is scheduled. Similarly, the application must ensure that it disables DMA using LCDIDDDMADisable() before making a call to LCDIDDCommandWrite(), LCDIDDStatusRead(), LCDIDDDataWrite(), LCDIDDDataRead(), LCDIDDIndexedWrite() or LCDIDDIndexedRead(). 本帖最后由 平湖秋月 于 2014-1-6 13:25 编辑
点赞  2014-1-5 17:23
Raster Mode--光栅模式 Raster mode connects both passive- and active-matrix displays using a traditional video-style, synchronous interface based on VSYNC (LCDFP), HSYNC (LCDLP), VALID (LCDAC), CLK (LCPCP) and DATA (LCDDATA) signals. Unlike LIDD displays which contain their own frame buffer, the display image for a raster display is stored in internal or EPI-attached memory and is scanned to the display using the LCD controller hardware and appropriate refresh rate and line timings provided by the application. The function LCDModeSet() with parameter ui8Mode set to LCD_MODE_RASTER will select the raster controller mode. This function also sets the required pixel clock frequency. Note that this must be an integer factor of the system clock frequency so applications must ensure that they choose an appropriate system clock frequency to allow the required pixel clock to be set. In cases where the current system clock setting is such that the exact requested pixel clock cannot be set, LCDModeSet() will set the closest lower pixel clock that can be derived given the current system clock frequency and will return that frequency to the caller. Properties of the display being driven can be set using a call to the function LCDRasterConfigSet(). This configures active- or passive-matrix display, how the color palette is used and various parameters relating to the packing order of pixels in memory. Raster timings and signal polarities are configured using a call to LCDRasterTimingSet(). The frame buffer, whose layout is described in the following section, is configured using a call to LCDRasterFrameBufferSet() which accepts parameters indicating the address of the start of the buffer in memory and its size. Because the frame buffer also contains the pixel format identifier and color palette in addition to the pixel data, LCDRasterPaletteSet() must be called to initialize the palette and format header before the raster is enabled. This is required for all pixel formats, even those which do not require a color lookup table, to ensure correct display. Once all controller and frame buffer initialization is complete, the display raster can be enabled by calling LCDRasterEnable(). If the display is to be shut down at any point, LCDRasterDisable() may be used. The LCD controller also supports a subpanel mode which may be helpful in memory constrained systems. This allows the active area on the display to be set to use a number of lines less than the native height. Lines above or below the active area are filled with a default color. The subpanel may be configured using LCDRasterSubPanelConfigSet() which defines the split point between active image and default color and also determines whether the active image area is above or below the split line. When a subpanel is configured, LCDRasterFrameBufferSet() can be called with a frame buffer sized for the number of lines in the subpanel rather than the whole screen. The subpanel may be enabled using LCDRasterSubPanelEnable() and disabled using LCDRasterSubPanelDisable(). 本帖最后由 平湖秋月 于 2014-1-6 13:26 编辑
点赞  2014-1-5 17:23
19.2.4 Frame Buffer and Palette Formats--帧缓冲与调色板格式 When using raster mode, the frame buffer is stored in local SRAM or EPI- connected SDRAM and the application is responsible for ensuring that it is formatted correctly for the LCD controller’s current configuration. The frame buffer contains two sections: A header containing the pixel format identifier and palette (color lookup table). This contains either 16 or 128 16-bit entries. An array of pixels comprising the image to display. The frame buffer header is 8 words (or 16 half-word palette entries) long when displaying any pixel format other than 8 bits-per-pixel in which case it is 128 words (256 half-word palette entries) in length. Note that the header cannot be removed even when using pixel formats which do not require a palette. Each entry in the header comprises a 16-bit half-word containing a 12-bit RGB444 color in the bottom 12 bits. The top 4 bits of each entry other than the first are reserved and must be set to 0. The top 4 bits of the first entry contains an identifier informing the LCD controller of the color depth (1-, 2-, 4- or 8-bpp palettized, or direct color 12-, 16- or 24-bpp) in use for the following image data. The frame buffer type identifier may be set by calling LCDRasterPaletteSet() or by directly writing the first half-word of the frame buffer header with LCD_PALETTE_TYPE_1BPP, LCD_PALETTE_TYPE_2BPP, LCD_PALETTE_TYPE_4BPP, LCD_PALETTE_TYPE_8BPP or LCD_PALETTE_TYPE_DIRECT. 本帖最后由 平湖秋月 于 2014-1-6 13:27 编辑
点赞  2014-1-5 17:24
没东西。
点赞  2014-1-5 20:01
. 本帖最后由 平湖秋月 于 2014-1-6 10:27 编辑
点赞  2014-1-5 21:22
本帖最后由 平湖秋月 于 2014-1-6 10:27 编辑
点赞  2014-1-5 21:23
(). 本帖最后由 平湖秋月 于 2014-1-6 10:28 编辑
点赞  2014-1-5 21:24
本帖最后由 平湖秋月 于 2014-1-6 10:29 编辑
点赞  2014-1-5 21:24
本帖最后由 平湖秋月 于 2014-1-6 10:29 编辑
点赞  2014-1-5 21:25
19.2.2 LCD Interface Display Driver (LIDD) Mode The LIDD mode controller allows connection of displays via a synchronous or asynchronous interface 本帖最后由 平湖秋月 于 2014-1-6 10:30 编辑
点赞  2014-1-5 21:25

光栅格式演示程序段

引用: 平湖秋月 发表于 2014-1-5 21:25 19.2.2 LCD Interface Display Driver (LIDD) Mode The LIDD mode controller allows connection of disp ...
下面的程序段演示如何使用LCD控制器API来配置一个800x480分辨率的光栅板,并以8bpp帧缓冲格式显示。注意:配置光栅时序时需考虑不同显示器的差异。根据您的显示器实际修改tLCDRaster结构体的时序值。 //***************************************************************************** // // Define the frame buffer dimensions and format. // //***************************************************************************** #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 480 #define SCREEN_BPP 8 //***************************************************************************** // //分类定义包含图像的位图和调色板的大小。 // //***************************************************************************** #define SIZE_IMAGE ((SCREEN_WIDTH * SCREEN_HEIGHT * SCREEN_BPP) / 8) #define SIZE_PALETTE ((SCREEN_BPP == 8) ? (256 * 2) : (16 * 2)) //***************************************************************************** //帧缓冲在存储器中的适当存储单元,最有可能在 连接的EPI SDRAM中的0x10000000单元。 // The frame buffer will be (SIZE_IMAGE + SIZE_PALETTE) bytes long. // //***************************************************************************** uint32_t *g_pui32DisplayBuffer = (uint32_t *)LCD_FRAME_BUFFER_ADDR; //***************************************************************************** //计算指向调色板的帧缓冲器和实际位图第一个字节的指针。 // //***************************************************************************** uint16_t *g_pui16Palette = (uint16_t *)LCD_FRAME_BUFFER_ADDR; uint8_t *g_pBitmap = (uint8_t *)(LCD_FRAME_BUFFER_ADDR + SIZE_PALETTE); //***************************************************************************** // // Initialize our source color palette. These colors are defined in RGB888 // format as used by the TivaWare Graphics Library.注意这个定义在TivaWare图像库中 //说明这里采用8bpp格式显示,所以颜色被定义成RGB888,而市面上常用的 是16bpp格式显示,即RGB565格式。 //***************************************************************************** const uint32_t g_pulSrcPalette[256] = { ClrBlack, ClrWhite, ClrRed, ClrLightGreen, ClrBlue, ClrYellow, ClrMagenta, ClrCyan, ClrOrange, // // and so on... // }; //***************************************************************************** // //分类定义所需的像素时钟,PLL VCO频率和系统时钟。 // Note that the system clock must be an integer multiple of the pixel clock.系统时钟为像素的 //整数倍 //***************************************************************************** #define PIXEL_CLOCK_FREQ 30000000 #define SYSTEM_VCO_FREQ SYSCTL_CFG_VCO_480 #define SYSTEM_CLOCK_FREQ 120000000 //***************************************************************************** // // 各种光栅接口信号的时序和信号极性。 //时序参数用像素时钟(水平时序)和线(垂直时序)来定义。 //***************************************************************************** tLCDRasterTiming g_sRasterTimings = { (RASTER_TIMING_ACTIVE_HIGH_PIXCLK | RASTER_TIMING_SYNCS_ON_RISING_PIXCLK), SCREEN_WIDTH, SCREEN_HEIGHT, 2, 30, 8, 10, 10, 8, 0 }; //***************************************************************************** // // LCD控制器的中断处理程序。此函数只计算接收中断。 // //***************************************************************************** void LCDIntHandler(void) { uint32_t ui32Status; // // Get the current interrupt status and clear any active interrupts. // ui32Status = LCDIntStatus(LCD0_BASE, true); LCDIntClear(LCD0_BASE, ui32Status); // // Handle any interrupts as required by the application. In normal // operation, no action is required at interrupt time to keep the raster // scan running. // } //***************************************************************************** //初始化LCD控制器来驱动光栅显示模式并使能光栅引擎。 // //***************************************************************************** void InitDisplay(uint32_t ui32SysClkHz, uint32_t ui32PixClock, tLCDRasterTiming *psTimings) { uint32_t ui32Loop; // // Enable the LCD controller peripheral.使能外设 // SysCtlPeripheralEnable(SYSCTL_PERIPH_LCD0); // // Wait to ensure that the LCD controller is enabled. // SysCtlDelay(2); // // Configure the LCD controller for raster operation with a pixel clock // as close to the requested pixel clock as possible.配置光栅操作 // ui32PixClock = LCDModeSet(LCD0_BASE, (LCD_MODE_RASTER | LCD_MODE_AUTO_UFLOW_RESTART), ui32PixClock, ui32SysClkHz); // // Set the output format for the raster interface.设置光栅接口的输出格式 // LCDRasterConfigSet(LCD0_BASE, RASTER_FMT_ACTIVE_PALETTIZED_16BIT, 0); // // Program the raster engine timings according to the display requirements. //编程光栅引擎时序 LCDRasterTimingSet(LCD0_BASE, psTimings); // // Configure LCD DMA-related parameters.配置DMA相关参数 // LCDDMAConfigSet(LCD0_BASE, LCD_DMA_BURST_4); // // Set up the frame buffer.设置帧缓冲 // LCDRasterFrameBufferSet(LCD0_BASE, 0, g_pui32DisplayBuffer, SIZE_PALETTE + SIZE_IMAGE); // // 写调色板的帧缓冲区。 // LCDRasterPaletteSet(LCD0_BASE, LCD_PALETTE_SRC_24BIT | LCD_PALETTE_TYPE_8BPP, (uint32_t *)g_pui16Palette, g_pulSrcPalette, 0, (SIZE_PALETTE / 2)); // // 用黑色填充帧缓冲区(像素值0对应黑色,我们刚才设置的调色板)。 // for(ui32Loop = 0; ui32Loop < (SIZE_IMAGE / sizeof(uint32_t)); ui32Loop++) { g_pui32DisplayBuffer[ui32Loop] = 0; } // // Enable the LCD interrupts. // LCDIntEnable(LCD0_BASE, (LCD_INT_DMA_DONE | LCD_INT_RASTER_FRAME_DONE | LCD_INT_SYNC_LOST | LCD_INT_AC_BIAS_CNT | LCD_INT_UNDERFLOW | LCD_INT_PAL_LOAD | LCD_INT_EOF0 | LCD_INT_EOF1)); IntEnable(INT_LCD0); // // Enable the raster output. // LCDRasterEnable(LCD0_BASE); } //***************************************************************************** // // This example demonstrates the use of the LCD Controller in raster mode. //这个例子演示了如何使用光栅模式的LCD控制器。 //***************************************************************************** int main(void) { uint32_t ui32SysClock; // // 设置系统时钟从PLL在120 MHz运行。 // ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSTEM_VCO_FREQ), SYSTEM_CLOCK_FREQ); // // Configure the device pins.引脚配置 // PinoutSet(); // // Enable interrupts in the CPU. // IntMasterEnable(); // // Initialize the display controller and start the raster engine. // InitDisplay(ui32SysClock, PIXEL_CLOCK_FREQ, &g_sRasterTimings); while(1) { // // Other application code... // } } 本帖最后由 平湖秋月 于 2014-1-6 13:28 编辑
点赞  2014-1-6 10:55
引用: tLCDRasterTiming结构体定义:
typedef struct { uint32_t ui32Flags; uint16_t ui16PanelWidth; uint16_t ui16PanelHeight; uint16_t ui16HFrontPorch; uint16_t ui16HBackPorch; uint16_t ui16HSyncWidth; uint8_t ui8VFrontPorch; uint8_t ui8VBackPorch; uint8_t ui8VSyncWidth; uint8_t ui8ACBiasLineCount; } tLCDRasterTiming Members: ui32Flags Flags configuring the polarity and active edges of the various signals in the raster interface. This field is comprised of a logical OR of the labels with prefix “RASTER_TIMING_”. ui16PanelWidth The number of pixels contained within each line on the LCD display. Valid values are multiple of 16 less than or equal to 2048. ui16PanelHeight The number of lines on the LCD display. Valid values are from 1 to 2048. ui16HFrontPorch A value from 1 to 1024 that specifies the number of pixel clock periods to add to the end of each line after active video has ended. ui16HBackPorch A value from 1 to 1024 that specifies the number of pixel clock periods to add to the beginning of a line before active video is asserted. ui16HSyncWidth A value from 1 to 1024 that specifies the number of pixel clock periods to pulse the line clock at the end of each line. ui8VFrontPorch A value from 0 to 255 that specifies the number of line clock periods to add to the end of each frame after the last active line. ui8VBackPorch A value from 0 to 255 that specifies the number of line clock periods to add to the beginning of a frame before the first active line is output to the display. ui8VSyncWidth In active mode, a value from 1 to 64 that specifies the number of line clock periods to set the lcd_fp pin active at the end of each frame after the vertical front porch period elapses. The number of The frame clock is used as the VSYNC signal in active mode. In passive mode, a value from 1 to 64 that specifies the number of extra line clock periods to insert after the vertical front porch period has elapsed. Note that the width of lcd_fp is not affected by this value in passive mode. ui8ACBiasLineCount A value from 0 to 255 that specifies the number of line clocks to count before transitioning the AC Bias pin. This pin is used to periodically invert the polarity of the power supply to prevent DC charge build-up within the display. Description:功能描述 光栅接口包含时序参数的结构体。用于LCDRasterTimingSet函数。 本帖最后由 平湖秋月 于 2014-1-6 13:32 编辑
点赞  2014-1-6 10:58
带lcd的只能是BGA封装的,就目前ti的芯片推动,用的人会很少。
点赞  2014-1-6 13:34
引用: 慢慢来 发表于 2014-1-6 13:34 带lcd的只能是BGA封装的,就目前ti的芯片推动,用的人会很少。
我找到一个TM4C123G129开发板的液晶驱动程序,贴给坛友以便进一步讨论 LCD控制器的使用方法 //***************************************************************************** #define LCD_HORIZONTAL_MAX 320 #define LCD_VERTICAL_MAX 240 //***************************************************************************** // // Translates a 24-bit RGB color to a display driver-specific color. // // \param c is the 24-bit RGB color. The least-significant byte is the blue // channel, the next byte is the green channel, and the third byte is the red // channel. // // This macro translates a 24-bit RGB color into a value that can be written // into the display's frame buffer in order to reproduce that color, or the // closest possible approximation of that color. // // \return Returns the display-driver specific color. // //***************************************************************************** #define DPYCOLORTRANSLATE(c) ((((c) & 0x00f80000) >> 8) | \ (((c) & 0x0000fc00) >> 5) | \ (((c) & 0x000000f8) >> 3)) //***************************************************************************** // // Writes a data word to the SSD2119. // //***************************************************************************** static inline void WriteData(uint16_t ui16Data) { // // Split the write into two bytes and pass them to the LCD controller. // LCDIDDDataWrite(LCD0_BASE, 0, ui16Data >> 8); LCDIDDDataWrite(LCD0_BASE, 0, ui16Data & 0xff); } //***************************************************************************** // // Writes a command to the SSD2119. // //***************************************************************************** static inline void WriteCommand(uint8_t ui8Data) { // // Pass the write on to the controller. // LCDIDDCommandWrite(LCD0_BASE, 0, (uint16_t)ui8Data); } //***************************************************************************** static void Kentec320x240x16_SSD2119PixelDraw(void *pvDisplayData, int32_t i32X, int32_t i32Y, uint32_t ui32Value) { // // Set the X address of the display cursor. // WriteCommand(SSD2119_X_RAM_ADDR_REG); WriteData(MAPPED_X(i32X, i32Y)); // // Set the Y address of the display cursor. // WriteCommand(SSD2119_Y_RAM_ADDR_REG); WriteData(MAPPED_Y(i32X, i32Y)); // // Write the pixel value. // WriteCommand(SSD2119_RAM_DATA_REG); WriteData(ui32Value); } // // Set the display cursor to the upper left of the rectangle (in // application coordinate space). // WriteCommand(SSD2119_X_RAM_ADDR_REG); WriteData(MAPPED_X(psRect->i16XMin, psRect->i16YMin)); WriteCommand(SSD2119_Y_RAM_ADDR_REG); WriteData(MAPPED_Y(psRect->i16XMin, psRect->i16YMin)); // // Tell the controller to write data into its RAM. // WriteCommand(SSD2119_RAM_DATA_REG); // // Loop through the pixels of this filled rectangle. // for(i32Count = ((psRect->i16XMax - psRect->i16XMin + 1) * (psRect->i16YMax - psRect->i16YMin + 1)); i32Count >= 0; i32Count--) { // // Write the pixel value. // WriteData(ui32Value); } // // Reset the X extents to the entire screen. // WriteCommand(SSD2119_H_RAM_START_REG); WriteData(0x0000); WriteCommand(SSD2119_H_RAM_END_REG); WriteData(0x013f); // // Reset the Y extent to the full screen // WriteCommand(SSD2119_V_RAM_POS_REG); WriteData(0xef00); } LCDIDDConfigSet(LCD0_BASE, LIDD_CONFIG_ASYNC_MPU80); 本帖最后由 平湖秋月 于 2014-1-7 22:09 编辑
点赞  2014-1-6 16:06

我只有很多的tm4c123G,在弄oled,期待楼主大作。
点赞  2014-1-6 19:38
支持楼主,,,还是有LCD控制器了爽
点赞  2014-1-6 22:01

  • lcd框图.JPG
点赞  2014-1-7 13:47
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复