LCD component
LCD component
The LCD component is used to drive a single graphics LCD module up to 800 * 600 pixels with pixel clocks of up to 25MHz.
Features
- Standard component to support different LCD displays with an RGB interface.
- Different color depths 32 bpp, 16 bpp, etc. based on user configuration.
- Resolution of up to 800 * 600 pixels.
- Outputs to a CMOS interface.
- Configurability of
* LCD pixel dimensions,
* clock rate,
* horizontal and vertical timing requirements,
* port mapping of the LCD.- Requires a single core for the server.
* The function lcd_server requires just one core, the client functions, located in lcd.h are very low overhead and are called from the application.
Memory requirements
Resource |
Usage |
---|---|
Stack |
92 bytes |
Program |
2168 bytes |
Resource requirements
Resource |
Usage |
---|---|
Channels |
1 |
Timers |
0 |
Clocks |
1 |
Logical Cores |
1 |
Performance
The achievable effective bandwidth varies according to the available xCORE MIPS. The maximum pixel clock supported is 25MHz.
Touch screen component
The touch screen component is used to read the touch coordinates from the touch screen controller AD7879-1.
Features
- Standard components to support touch screen controller with I2C serial interface
- Supports 4-wire resistive touch screens of different sizes
- Resolution of 4096 * 4096 points
- Pen-down interrupt signal supported
- Outputs touch coordinates
- module_touch_controller_lib requires a single core while module_touch_controller_server requires an additional core for the server.
Memory requirements
app_touch_controller_lib_demo
Resource |
Usage |
---|---|
Stack |
304 bytes |
Program |
3160 bytes |
app_touch_controller_server_demo
Resource |
Usage |
---|---|
Stack |
420 bytes |
Program |
3576 bytes |
Resource requirements
app_touch_controller_lib_demo
Resource |
Usage |
---|---|
Channels |
0 |
Timers |
3 |
Clocks |
1 |
Logical Cores |
1 |
app_touch_controller_server_demo
Resource |
Usage |
---|---|
Channels |
1 |
Timers |
3 |
Clocks |
1 |
Logical Cores |
2 |
Recommended Hardware
sliceKIT
This module may be evaluated using the sliceKIT Modular Development Platform, available from digikey. Required board SKUs are:
- XP-SKC-L2 (sliceKIT L16 Core Board) plus XA-SK-SCR480 plus XA-SK-XTAG2 (sliceKIT XTAG adaptor)
Demonstration applications
LCD Demo Application
The LCD demo application shows how a buffer of image data can be written to the 480×272 LCD screen that is supplied with the XA-SK-SCR480 Slice Card.
- Package: sc_lcd
- Application: app_lcd_demo
Touch screen demo application
The touch screen demo application shows how a touch event is processed and the touch coordinates are fetched from the touch screen controller chip fitted on the XA-SK-SCR480 Slice Card.
- Package: sc_lcd
- Applications: app_touch_controller_lib_demo
Display controller application
This combination demo employs the module_lcd along with the module_sdram and the module_display_controller framebuffer framework component to implement a 480×272 display controller.
Required board SKUs for this demo are:
- XP-SKC-L2 (sliceKIT L16 Core Board) plus XA-SK-XTAG2 (sliceKIT XTAG adaptor)
- XA-SK-SCR480 for the LCD
- XA-SK-SDRAM for the SDRAM
- Package: sw_display_controller
- Application: app_display_controller
The component sc_lcd includes the modules module_lcd, module_text_display and module_touch_controller_lib.
module_lcd
Configuration defines
The module_lcd includes device support defines, each support header, located in the devices directory defines a number of parameters. It is sufficient for the user to specify which device to support in the lcd_conf.h for the device to be correctly supported. To do this lcd_conf.h must include the define:
::
#define LCD_PART_NUMBER p
- where p is the part the user requires support for. lcd_conf.h must be located in the application project and not the module. Currently, support is provided for:
-
- AT043TN24V7
- K430WQAV4F
- K70DWN0V1F
Implementation specific defines
It is possible to override the default defines when a part number is selected. The defines available are:
- LCD_WIDTH
-
This define is used to represent the width of the LCD panel in pixels.
- LCD_HEIGHT
-
This define is used to represent the height of the LCD panel in pixels.
- LCD_BITS_PER_PIXEL
-
Count of bits used to set a pixels RGB value, i.e. if the screen was wired for rgb565 then the LCD_BITS_PER_PIXEL would be 16, rgb888 would be 24. This is independant of the actual bit depth of the lcd.
- LCD_HOR_FRONT_PORCH
-
The horizontal front porch timing requirement given in pixel clocks.
- LCD_HOR_BACK_PORCH
-
The horizontal back porch timing requirement given in pixel clocks.
- LCD_VERT_FRONT_PORCH
-
The vertical front porch timing requirement given in horizontal time periods.
- LCD_VERT_BACK_PORCH
-
The vertical back porch timing requirement given in horizontal time periods.
- LCD_HOR_PULSE_WIDTH
-
The horizontal pulse width timing requirement given in pixel clocks. This is the duration that the hsync signal should go low to denote the start of the horizontal frame. Set to 0 when hsync is not necessary.
- LCD_VERT_PULSE_WIDTH
-
The vertical pulse width timing requirement given in vertical time periods. This is the duration that the vsync signal should go low to denote the start of the vertical frame. Set to 0 when vsync is not necessary.
- LCD_FREQ_DIVIDEND
-
The defines FREQ_DIVIDEND and FREQ_DIVISOR are used to calculate the frequency of the clock used for LCD. The frequency configured = (FREQ_DIVIDEND / FREQ_DIVISOR) in MHz
- LCD_FREQ_DIVISOR
-
The defines FREQ_DIVIDEND and FREQ_DIVISOR are used to calculate the frequency of the clock used for LCD. The frequency configured = (FREQ_DIVIDEND / FREQ_DIVISOR) in MHz
- LCD_FAST_WRITE
-
The define enables a faster LCD write function, however, it produces more code. Use when a 25MHz pixel clock is required. It cannot be used with LCD_HOR_PULSE_WIDTH > 0 or LCD_VERT_PULSE_WIDTH > 0 as horizontal and veritcal sync signals are not supported in LCD_FAST_WRITE mode.
API
- The LCD display module functionality is defined in
-
- lcd.xc
- lcd.h
- lcd_defines.h
- lcd_assembly.S
- /devices
where the following functions can be found:
-
void lcd_init(chanend c_lcd)
LCD init function.
This sets the lcd into a state where it is ready to accept data.
Parameters
-
c_lcd
The channel end connecting to the lcd server.
-
-
static void lcd_req(chanend c_lcd)
Receives the request for data from the LCD server.
Parameters
-
c_lcd
The channel end connecting to the lcd server.
-
-
static void lcd_update(chanend c_lcd, unsigned buffer[])
LCD update function.
This sends a buffer of data to the lcd server to to sent to the lcd.
Note, no array bounds checking is performed.
Parameters
-
c_lcd
The channel end connecting to the lcd server.
-
buffer[]
The data to be emitted to the lcd screen, stored in rgb565.
-
-
static void lcd_update_p(chanend c_lcd, unsigned buffer)
C interface for LCD update function.
This sends a buffer of data to the lcd server to to sent to the lcd.
Note, no array bounds checking is performed.
Parameters
-
c_lcd
The channel end connecting to the lcd server.
-
buffer
A pointer to data to be emitted to the lcd screen, stored in rgb565.
-
-
void lcd_server(chanend c_client, lcd_ports &ports)
The LCD server thread.
Parameters
-
c_client
The channel end connecting to the client.
-
ports
The structure carrying the LCD port details.
-
module_touch_controller_lib
The device-specific configuration defines and user defines are listed in touch_lib_conf.h.
Configuration defines
- TOUCH_LIB_LCD_WIDTH
-
This define is used to represent the width of the LCD panel in pixels.
- TOUCH_LIB_LCD_HEIGHT
-
This define is used to represent the height of the LCD panel in pixels.
- TOUCH_LIB_TS_WIDTH
-
This define is used to represent the width of the touch screen in points.
- TOUCH_LIB_TS_HEIGHT
-
This define is used to represent the height of the touch screen in points.
API
- The touch screen module functionality is defined in
-
- touch_controller_lib.xc
- touch_controller_lib.h
- /AD7879-1
where the following functions can be found:
-
void touch_lib_init(touch_controller_ports &ports)
The touch controller initialisation.
Parameters
-
ports
The structure containing the touch controller port details.
-
-
void touch_lib_get_touch_coords(touch_controller_ports &ports, unsigned &x, unsigned &y)
Get the current touch coordinates from the touch controller.
The returned coordinates are not scaled.
Parameters
-
ports
The structure containing the touch controller port details.
-
x
The X coordinate of point of touch.
-
y
The Y coordinate of point of touch.
-
-
select touch_lib_touch_event(touch_controller_ports &ports)
A select function that will wait until the touch controller reports a touch event.
Parameters
-
ports
The structure containing the touch controller port details.
-
-
void touch_lib_get_next_coord(touch_controller_ports &ports, unsigned &x, unsigned &y)
This function will block until the controller reports a touch event at which point it will return the coordinates of that event.
The coordinates are not scaled.
Parameters
-
ports
The structure containing the touch controller port details.
-
x
The X coordinate of point of touch.
-
y
The Y coordinate of point of touch.
-
-
void touch_lib_scale_coords(unsigned &x, unsigned &y)
The function to scale coordinate values (from the touch point coordinates to the LCD pixel coordinates).
Parameters
-
x
The scaled X coordinate value
-
y
The scaled Y coordinate value
-
This section provides information on how to program applications using the LCD module.
Source code structure
Project |
File |
Description |
---|---|---|
module_lcd |
lcd.h |
Header file containing the APIs for the LCD component |
lcd.xc |
File containing the implementation of the LCD component |
|
lcd_defines.xc |
Header file containing the user configurable defines for the LCD |
|
lcd_assembly.S |
Assembly file containing the fast_write functionality for the LCD. |
|
/devices |
Folder containing header files of configurations for LCDs |
Additional files
File name |
Description |
---|---|
generate.pl |
Perl file for generating a fast write function body for LCD screens of arbitrary width. |
How to select the LCD target
The module has been designed to support multiple LCD targets. Each target has a specific configuration and have been provided
with the component int the /devices directory. The module only supports a single LCD target per xCORE.
To select the target the following should be done:
- If the required target is the part AT043TN24V7 LCD display then,
-
- Create a header in the application project called lcd_conf.h
- In the lcd_conf.h add the define #define LCD_PART_NUMBER AT043TN24V7. This will include the “lcd_defines_AT043TN24V7.h” required for the selected target.
- Any specific overrides should be added to the lcd_conf.h. For example, to override the LCD_HEIGHT to 600 pixels add the line #define LCD_HEIGHT 600.
- The application should also include the port mapping for the LCD as per the hardware used. A variable of the type structure lcd_ports should be created and must include the port information
Example:
In the application file
struct lcd_ports lcd_ports = { XS1_PORT_1G, XS1_PORT_1F, XS1_PORT_16A, XS1_PORT_1B, XS1_PORT_1C, XS1_CLKBLK_1 };
The declared variable lcd_ports is used by the LCD server call to address these ports. A core should have the lcd_server running on it and it should be connected by a channel to the application, for example:
chan c_lcd; par { lcd_server(c_lcd, lcd_ports); application(c_lcd); }
Executing the project
The module by itself cannot be built or executed separately. It must be linked in to an application which needs LCD display. Once the module is linked to the application, the application can be built and tested for driving a LCD screen.
- The following should be done in order to link the component to the application project
-
- The module name module_lcd should be added to the list of MODULES in the application project build options.
- Now the module is linked to the application and can be directly used
Software requirements
The module is built on XDE Tool version 12.0
The module can be used in version 12.0 or any higher version of xTIMEcomposer.
This section provides information on how to program applications using the touch controller module.
Source code structure
Project |
File |
Description |
---|---|---|
module_touch_controller_lib |
touch_controller_lib.h |
Header file containing the APIs for interfacing touch controller component |
touch_controller_lib.xc |
File containing the implementation of APIs |
|
/AD7879-1 |
Folder containing files for the implementation of touch controller component |
|
touch_controller_impl.h |
Header file containing the APIs for implementing touch controller component |
|
touch_controller_impl.xc |
File containing the implementation of touch controller component |
|
module_touch_controller_server |
touch_controller_server.h |
Header file containing the APIs for interfacing touch controller component |
touch_controller_server.xc |
File containing the implementation of APIs |
|
/AD7879-1 |
Folder containing files for the implementation of touch controller component |
|
touch_controller_impl.h |
Header file containing the APIs for implementing touch controller component |
|
touch_controller_impl.xc |
File containing the implementation of touch controller component |
How to develop an application
The modules have been designed to support two types of interfacing with the touch screen controller; one for direct interfacing and the other for interfacing through a server. Only one of these two modules should be used by the application program.
- To use a module,
-
- Create a header file in the application project called touch_lib_conf.h or touch_server_conf.h.
- In the header file, add the defines for conditional compilation and device-specific parameters.
- The application should also include the port mapping for the touch screen controller. A variable of the type structure touch_controller_ports should be created and must include the port information.
Example:
In the application file
struct touch_controller_ports ports = { XS1_PORT_1E, XS1_PORT_1H, 1000, XS1_PORT_1D };
When module_touch_controller_server is used, a core should have the touch_controller_server running on it and it should be connected by a channel to the application, for example:
chan c; par { touch_controller_server(c, ports); app(c); }
Executing the project
The touch controller module by itself cannot be built or executed separately. It must be linked into an application. The application also depends on I2C module. Once the modules are linked to the application, the application can be built and run.
- The following should be done in order to link the modules to the application project.
-
- The module name module_touch_controller_lib or module_touch_controller_server should be added to the list of MODULES in the application project build options.
- The module name module_i2c_master should also be added.
- Now the modules are linked to the application and can be directly used
Software requirements
The modules are built on XDE Tool version 12.0
The modules can be used in version 12.0 or any higher version of xTIMEcomposer.
This section provides information on how to program applications using the LCD module.
Source code structure
Project |
File |
Description |
---|---|---|
module_lcd |
lcd.h |
Header file containing the APIs for the LCD component |
lcd.xc |
File containing the implementation of the LCD component |
|
lcd_defines.xc |
Header file containing the user configurable defines for the LCD |
|
lcd_assembly.S |
Assembly file containing the fast_write functionality for the LCD. |
|
/devices |
Folder containing header files of configurations for LCDs |
Additional files
File name |
Description |
---|---|
generate.pl |
Perl file for generating a fast write function body for LCD screens of arbitrary width. |
How to select the LCD target
The module has been designed to support multiple LCD targets. Each target has a specific configuration and have been provided
with the component int the /devices directory. The module only supports a single LCD target per xCORE.
To select the target the following should be done:
- If the required target is the part AT043TN24V7 LCD display then,
-
- Create a header in the application project called lcd_conf.h
- In the lcd_conf.h add the define #define LCD_PART_NUMBER AT043TN24V7. This will include the “lcd_defines_AT043TN24V7.h” required for the selected target.
- Any specific overrides should be added to the lcd_conf.h. For example, to override the LCD_HEIGHT to 600 pixels add the line #define LCD_HEIGHT 600.
- The application should also include the port mapping for the LCD as per the hardware used. A variable of the type structure lcd_ports should be created and must include the port information
Example:
In the application file
struct lcd_ports lcd_ports = { XS1_PORT_1G, XS1_PORT_1F, XS1_PORT_16A, XS1_PORT_1B, XS1_PORT_1C, XS1_CLKBLK_1 };
The declared variable lcd_ports is used by the LCD server call to address these ports. A core should have the lcd_server running on it and it should be connected by a channel to the application, for example:
chan c_lcd; par { lcd_server(c_lcd, lcd_ports); application(c_lcd); }
Executing the project
The module by itself cannot be built or executed separately. It must be linked in to an application which needs LCD display. Once the module is linked to the application, the application can be built and tested for driving a LCD screen.
- The following should be done in order to link the component to the application project
-
- The module name module_lcd should be added to the list of MODULES in the application project build options.
- Now the module is linked to the application and can be directly used
Software requirements
The module is built on XDE Tool version 12.0
The module can be used in version 12.0 or any higher version of xTIMEcomposer.
This section provides information on how to program applications using the touch controller module.
Source code structure
Project |
File |
Description |
---|---|---|
module_touch_controller_lib |
touch_controller_lib.h |
Header file containing the APIs for interfacing touch controller component |
touch_controller_lib.xc |
File containing the implementation of APIs |
|
/AD7879-1 |
Folder containing files for the implementation of touch controller component |
|
touch_controller_impl.h |
Header file containing the APIs for implementing touch controller component |
|
touch_controller_impl.xc |
File containing the implementation of touch controller component |
|
module_touch_controller_server |
touch_controller_server.h |
Header file containing the APIs for interfacing touch controller component |
touch_controller_server.xc |
File containing the implementation of APIs |
|
/AD7879-1 |
Folder containing files for the implementation of touch controller component |
|
touch_controller_impl.h |
Header file containing the APIs for implementing touch controller component |
|
touch_controller_impl.xc |
File containing the implementation of touch controller component |
How to develop an application
The modules have been designed to support two types of interfacing with the touch screen controller; one for direct interfacing and the other for interfacing through a server. Only one of these two modules should be used by the application program.
- To use a module,
-
- Create a header file in the application project called touch_lib_conf.h or touch_server_conf.h.
- In the header file, add the defines for conditional compilation and device-specific parameters.
- The application should also include the port mapping for the touch screen controller. A variable of the type structure touch_controller_ports should be created and must include the port information.
Example:
In the application file
struct touch_controller_ports ports = { XS1_PORT_1E, XS1_PORT_1H, 1000, XS1_PORT_1D };
When module_touch_controller_server is used, a core should have the touch_controller_server running on it and it should be connected by a channel to the application, for example:
chan c; par { touch_controller_server(c, ports); app(c); }
Executing the project
The touch controller module by itself cannot be built or executed separately. It must be linked into an application. The application also depends on I2C module. Once the modules are linked to the application, the application can be built and run.
- The following should be done in order to link the modules to the application project.
-
- The module name module_touch_controller_lib or module_touch_controller_server should be added to the list of MODULES in the application project build options.
- The module name module_i2c_master should also be added.
- Now the modules are linked to the application and can be directly used
Software requirements
The modules are built on XDE Tool version 12.0
The modules can be used in version 12.0 or any higher version of xTIMEcomposer.
This tutorial describes the demo applications included in the XMOS LCD software component.
Recommended Hardware
describes the required hardware setups to run the demos.
app_lcd_demo
This application demonstrates how the module is used to write image data to the LCD screen. The purpose of this application is to show how data is passed to the lcd_server
Application notes
- lcd_server requires a single logical core.
- lcd_init must be called before lcd_update_p or lcd_update are called. This puts the LCD server into a state ready to accept data.
- lcd_update and lcd_update_p are used to send an array of pixel data to the LCD server. There is a real-time requirement that this function is called often enough to maintain the display. lcd_update_p is the C interface to the LCD server, it takes a pointer to an array rather than the array itself.
- lcd_req is a function (also a select handler) that acknowledges the LCDs request for the next line of pixel data.
- The LCD server does no buffering of pixel line arrays, therefore, for every lcd_req there must be only one lcd_update or lcd_update_p. Likewise for every lcd_update or lcd_update_p there must be only one lcd_req.
- The pixel array must be on the same tile as the lcd_server.
Getting started
- Plug the XA-SK-LCD Slice Card into the ‘STAR’ slot of the sliceKIT Core Board
- Plug the XA-SK-XTAG2 Card into the sliceKIT Core Board.
- Ensure the XMOS LINK switch on the XA-SK-XTAG2 is set to “off”.
- Ensure the jumper on the XA-SK-SCR480 is bridged if the back light is required.
- Open app_lcd_demo.xc and build the project.
- Run the program
The output produced should look like a bouncing “X” on the LCD screen.
app_touch_controller_lib_demo
This application demonstrates how the module module_touch_controller_lib is used to fetch the touch coordinates from the touch screen controller.
Application notes
- touch_lib_init must be called before calling touch_lib_req_next_coord or/and touch_lib_req_next_coord_timed.
- touch_lib_req_next_coord and touch_lib_req_next_coord_timed wait for touch event and then read the touch coordinates stored in the result registers of touch screen controller. touch_lib_req_next_coord_timed computes the time delay in touch event from the function call.
Getting started
- Plug the XA-SK-LCD Slice Card into the ‘TRIANGLE’ slot of the sliceKIT Core Board
- Plug the XA-SK-XTAG2 Card into the sliceKIT Core Board.
- Click on the app_touch_controller_lib_demo and build the project.
- Run the demo.