Connecting the LCD
The K350QVG Smart LCD is a 3.5”(diagonal), 320 x RGB x 240 dots, 262K colors, Transmissive, TFT LCD module. It allows for either a parallel, or serial data bus, using the Solomon Systech SSD2119 LCD controller. This LCD can be connected in various different ways; in this application note, we discuss using it in 8-bit serial mode.
Interconnection
| Name | K350QVG Pin | QSK Pin | GPIO | Peripheral Mode | Snapper 9260 Pin |
| GND | 60,59,10,5 | 17,41,57,59 | - | - | - |
| VCC | 48,47,46 | 18,58 | - | - | - |
| DC | 49 | 38 | PB11 | - | 80 |
| PS3 | 55 | 18,58 | - | - | - |
| PS2 | 54 | 18,58 | - | - | - |
| PS1 | 53 | 18,58 | - | - | - |
| PS0 | 52 | 18,58 | - | - | - |
| SDA-SDI | 17 | 46 | PB1 | A | 58 |
| SPCLK | 16 | 48 | PB2 | A | 60 |
| CS | 15 | 50 | PB3 | A | 62 |
| RESET | 14 | 36 | PB21 | - | 72 |
Note: A 16-18V backlight supply, such as an FAN5333BSX, needs to be connected across LED_A & LED_K on the K350QVG connector (pins 4,3 & 2,1 respectively).
Software Control
Using the AT91SAM9260's internal SPI controller (SPI1) LCD data can be transmitted onto the SDA-SDI pin of the LCD. The DC pin (attached to gpio PB11) is used to control whether data, or register writes are being performed.
Register access
To write to the LCD registers:
- DC set low (PB11)
- 2-byte register address transmitted over the SPI bus, MSB first. CS line will automatically be driven low by the SPI controller
- DC set high (PB11)
- 2-byte register data transmitted over the SPI bus (MSB first).
Initialisation
To initialise the LCD perform the following steps:
- Register 0x10 (Sleep mode) set to 0x0001: Enter sleep mode
- Register 0x00 (Oscilation Start) set to 0x0001: Enable the LCD oscillator
- Register 0x01 (Driver output control) set to 0x30ef: Set up the LCD orientation
- Register 0x02 (LCD drive AC control) set to 0x0600: Set up LCD driving waveform
- Register 0x10 (Sleep mode) set to 0x0000: Exit sleep mode
- 30ms delay
- Register 0x07 (Display control) set to 0x0033: Turn on the display
Graphic Data Write
To write graphic data (in RGB 5:6:5 mode), perform the following steps:
- Register 0x4E (GDDRAM X address) set to X-coordinate
- Register 0x4F (GDDRAM Y address) set to Y-coordinate
- Register 0x22 (GDRAM Data) set to desired colour
Continues data write (DC set high) at this stage can be performed, and the address will automatically increment over to the next pixel (wrapping at the end of each line).
Connecting the Touch Screen
The K350QVG Smart LCD contains a standard four-wire touch screen made up of two flexible resistive sheets. Two of the wires connect to each end of one of the sheets in a horizontal orientation and the other two wires are connected to the other sheet in a vertical orientation. When the touch screen is pressed it shorts the two sheets at the point of contact. The process of reading the touch screen involves applying a constant voltage across one of the sheets and sampling an A/D connected to the second sheet. The A/D sample can be used to calculate the distance along the first sheets axis of orientation. A constant voltage is then applied across the second sheet to measure the touch point in the other direction.
Interconnection
This type of touch screen requires a minimum of 2 ADC's and 4 GPIO's to drive it. We use the ADC pins in both peripheral and GPIO mode and hence only need 4 physical pins.
| Name | K350QVG Pin | QSK Pin | GPIO | Peripheral Mode |
| TOUCH_YP | 9 | 15 | AD2/PC2 | A and GPIO |
| TOUCH_XN | 8 | 20 | PB6 | GPIO |
| TOUCH_YN | 7 | 22 | PB7 | GPIO |
| TOUCH_XP | 6 | 16 | AD3/PC3 | A and GPIO |
Sampling the touch screen
Sampling the touch screen is a 3 step process.
Detect Pen Down
The Pins should be setup as follows and the ADC sampled;
| XP | XN | YP | YN |
| VDD | GND | ADC | GND |
Because one end of the resistive plate is shorted to ground, the ADC sample will be zero if the touch screen is not currently being pressed. If this is the case, the pen is up and there is no point in sampling the x and y axis.
Read X Value
The Pins should be setup as follows and the ADC sampled;
| XP | XN | YP | YN |
| VDD | GND | ADC | Floating |
By sampling the ADC and calculating the ratio of ADC swing versus screen width, the X location can be found (i.e. (sample / 256) * 320).
Read Y Value
The Pins should be setup as follows and the ADC sampled;
| XP | XN | YP | YN |
| ADC | Floating | VDD | GND |
By sampling the ADC and calculating the ratio of ADC swing versus screen height, the X location can be found (i.e. (sample / 256) * 240).
Calibration and Debouncing
Every touch screen has slightly different characteristics and must be calibrated. This process involves sampling and storing known points on the screen and using them to translate every sampled value. For example, if the screen is pressed on the far left end and the ADC for x reads 16, then 16 must be subtracted from the screen x position calculation (i.e. (sample-16 / (256-16)) * 320).
The process outlined above for sampling the touch screen is much simplified. In reality the pen up/down status should be debounced, irregular samples should be discarded and there are better calibration algorithms available for accurate sampling.



