You have no items in your shopping cart.

Subtotal: 0.00

How to Interface SPI TFT with ARM9 Stick Board

ARM9-LPC2929 STICK BOARD

The is specifically designed to help students to master the required skills in the area of embedded systems. The board is designed in such way that all the possible features of the microcontroller will be easily used by the students. The board supports Keil µVision 4 compilers with Keil ULink2.

NXP Microcontroller,ARM9-LPC2929 stick board is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 32-bit Microcontrollers. It integrates CAN, LIN, UART, ADC, PWM, I2C, SPI, Timer, Interrupt etc., to create a stand-alone versatile test platform.

ARM9 Stick Board having more no of I/O line for user access able. Its consists of 64 GPIO pins, CAN0/1, LIN1, I2C0/1, UART0/1, SPI0/1, USB, ADC0/1/2, PWM, Timer and more features. Users can easily access the controller and develop more application by using ARM9 Stick Board.

TFT

A thin-film transistor (TFT) is a special kind of field-effect transistor made by depositing thin films of an active semiconductor layer as well as the dielectric layer and metallic contacts over a supporting (but non-conducting) substrate. A common substrate is glass, because the primary application of TFTs is in liquid-crystal displays.

 SPI_TFT 240x320

TFT SPI 240x320 LCD is used to display the 240x320 images and more special functions. The communication between

ARM9 Stick Board and TFT is SPI protocol. For that SPI0 (SCK0 and SDO0) in stick board to assign for TFT interface. And other control lines CS (Chip select), RST (Reset), D/C (Data/Command), LED (Back light of TFT) are used to control the operation of TFT.

The control lines are configure as GPIO and we can control manually when its need in function. The LED line is set at high by using program, then only the back light of TFT become glow

PROJECT DESCRIPTION

Connecting wires (Green Color wires):

The connecting wires are both sides having female type, because ARM9 stick and TFT models are having male type connector for interfacing.

Pin Details:

  • VCC - 3.3 V
  • GND - Ground
  • CS - Chip Select (Set this line as GPIO)
  • RST - Reset (Set this line as GPIO)
  • D/C - Data or Command (Set this line as GPIO)
  • MOSI - Mater Out Slave In (Configure this line as SPI0_SDO)
  • SCLK - SPI Clock (Configure this line as SPI0_SCK)
  • LED - Back Lighting LED (Configure this line as GPIO)
  • MISO - Master In Slave Out (NC)

Hardware's:

  • ARM9 Stick Board

  • ULink2 for Download program
  • TFT SPI 240x320
  • USB Micro cable (for Stick board Power and UART)
  • USB Mini cable (for ULink2)
  • 20 Pin FRC Cable (for interface Stick board and ULink)
  • Connecting Wires.

Software's:

  • Keil UVision4
  • Matlab R2010a
Functional Pin Diagram of

ARM9 Stick Board




functional-pin-diagram-of-arm9-stick-board

Front view of SPI_TFT 240x320


front-view-of-spi tft-240x320

Rear view of SPI_TFT 240x320


rear-view-of-spi tft-240x320

Circuit and Pin Diagram for ARM9 Stick Interface With SPI_TFT


circuit-and-pin-diagram-for-arm9-stick-interface-with-spi tft

Real view 1 of

ARM9 Stick Interface with SPI TFT



real-view-1-of-arm9-stick-interface-with-spi-tft

Real view 2 of

ARM9 Stick Interface with SPI TFT


real-view-2-of-arm9-stick-interface-with-spi-tft

Output of Displayed Image

spi-tft-arm9-stick-board-output-of-displayed-image

Creating Image file into 16 bit Hex Values using Matlab


creating-image-file-into-16-bit-hex-values-using-matlab

Copy the Image Header file and use this header file in Keil Project to Display an Image


header-file-in-keil-project-to-display-an-image

Downloading the Project file into Stick Board using Keil4


downloading-the-project-file-into-stick-board-using-keil4

C Program for Interfacing

ARM9 Stick Board and SPI TFT

Title: Program to SPI TFT Display

#include 

#include 

#include "Image.h"


#define WHITE 0xFFFF

#define BLACK 0x0000


#define SPI_ENABLE 0x1

#define SPI_MS_MODE 0x2

#define SPI_LOOPBACK_MODE 0x4

#define SPI_TRANSMIT_MODE 0x8

#define SPI_SLAVE_DISABLE 0x10

#define SPI_BUSY 0x10

#define SPI_TX_FIFO_FULL 0x2

#define SPI_RX_FIFO_FULL 0x8

#define SPI_RX_FIFO_EMPTY 0x4


#define LCD_W 240

#define LCD_H 320

#define LCD_DC 0x100

#define LCD_RST 0x020

#define CS0 0x040

#define LCD_BL 0x8000


void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);

void LCD_WR_DATA(unsigned int da);

void LCD_WR_DATA8(char da);

void LCD_WR_REG(char da);

void Lcd_Init(void);

void Show_Image(void);


void SPI_INT(void);

void SPI_Send(unsigned char Data );

void delayms(unsigned int count);


unsigned char SPI_Value;

unsigned int k;


int main()

{

GPIO1_DR |= LCD_RST|LCD_BL; // RST as O/P Direction

GPIO1_DR |= LCD_DC; // D/C as O/P Direction

GPIO1_OR |= LCD_BL; // Set LCD Backlight On

SFSP2_26 = 0x4; // Key fn as GPIO and Digital In without PU & PD


SPI_INT();

Lcd_Init();


Show_Image();

while(1);

}

void delayms(unsigned int count) // delay function

{

int i,j;

for(i=0;i<count;i++)

for(j=0;j<1000;j++);

}

void SPI_INT()

{

unsigned long regVal;

GPIO1_DR |= CS0; /* CS with Digital Output direction */

SFSP1_16 = 0xE; /* SCK with Digital no PU and PD, func. 2. */

SFSP1_17 = 0xE; /* SDI with Digital no PU and PD, func. 2. */

SFSP1_18 = 0xE; /* SDO with Digital no PU and PD, func. 2. */


SPI0_CONFIG &= ~SPI_ENABLE; // Disable SPI

SPI_CLK_CONF = CLK_SEL_XTAL | AUTOBLK | DIV2; // 6MHz /* BASE_SPI_CLK */

regVal = SPI0_CONFIG;

regVal &= ~(SPI_MS_MODE| SPI_LOOPBACK_MODE | SPI_TRANSMIT_MODE|SPI_SLAVE_DISABLE);

SPI0_CONFIG = regVal;

SPI0_SLV_ENABLE |= (1<<0);

SPI0_SLV0_SET1 |= (4<<8);

SPI0_SLV0_SET2 |= ((0<<6)|(1<<8)|(0x07));

SPI0_CONFIG |= (1<<7);

SPI0_CONFIG |= SPI_ENABLE;

}

void SPI_Send( unsigned char Data )

{

SPI_Value = (Data & 0xFF); // Write SPI data 8 bit

GPIO1_OR &= ~ CS0; // CS Low

while ( SPI0_STAT & SPI_BUSY ); // Wait untill SPI TX is done

if ( SPI0_STAT & SPI_TX_FIFO_FULL ) // If TX FIFO full, flush FIFO

{

SPI0_TX_FIFO_FLUSH = 1;

while ( SPI0_STAT & SPI_BUSY ); // Wait until flush is done

}

SPI0_FIFO_DATA = Data; // Shift data to buffer

for(k=0;k<1;k++); // delay for CS

GPIO1_OR |= CS0; // CS High

}

void LCD_WR_DATA8(char da)

{

GPIO1_OR |= LCD_DC;

SPI_Send(da);

}


void LCD_WR_DATA(unsigned int da)

{

GPIO1_OR |=LCD_DC;

SPI_Send(da>>8);

SPI_Send(da);

}

void LCD_WR_REG(char da)

{

GPIO1_OR &=~(LCD_DC);

SPI_Send(da);

}

void LCD_WR_REG_DATA(int reg,int da)

{

LCD_WR_REG(reg);

LCD_WR_DATA(da);

}

void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)

{

LCD_WR_REG (0x2a); // Coloum Address Set cmd

LCD_WR_DATA8 (x1>>8); // SC 16:8

LCD_WR_DATA8 (x1); // SC 7:0

LCD_WR_DATA8 (x2>>8); // EC 16:8

LCD_WR_DATA8 (x2); // EC 7:0

LCD_WR_REG (0x2b); // Page Address Set cmd

LCD_WR_DATA8 (y1>>8); // SP 16:8

LCD_WR_DATA8 (y1); // SP 7:0

LCD_WR_DATA8 (y2>>8); // EP 16:8

LCD_WR_DATA8 (y2); // EP 7:0

LCD_WR_REG (0x2C); // Memory write cmd

}

void Lcd_Init(void)

{

GPIO1_OR |= LCD_RST;

delayms(5);

GPIO1_OR &= ~LCD_RST;

delayms(5);

GPIO1_OR |= LCD_RST;


LCD_WR_REG (0xCB); // Power Control A cmd

LCD_WR_DATA8(0x39); // Parameter 1

LCD_WR_DATA8(0x2C); // Parameter 2

LCD_WR_DATA8(0x00); // Parameter 3

LCD_WR_DATA8(0x34); // Parameter 4 (Reg_VD=1.6)

LCD_WR_DATA8(0x02); // Parameter 5 (VBC=5.6)


LCD_WR_REG (0xCF); // Power Control B cmd

LCD_WR_DATA8(0x00); // Parameter 1

LCD_WR_DATA8(0XC1); // Parameter 2

LCD_WR_DATA8(0X30); // Parameter 3


LCD_WR_REG (0xE8); // Div Timing Control A cmd

LCD_WR_DATA8(0x85); // Parameter 1 (defualt+1)

LCD_WR_DATA8(0x00); // Parameter 2 (EQ & CR timing cont default-1)

LCD_WR_DATA8(0x78); // Parameter 3 (Precharge timimg cont default-2)

LCD_WR_REG (0xEA); // Div Timing Control B cmd

LCD_WR_DATA8(0x00); // Parameter 1 (EQ-G=0;EQ-DDVDH=0;EQ-DDVDH=0;EQ-G=0)

LCD_WR_DATA8(0x00); // Parameter 2

LCD_WR_REG (0xED); // Power Sequence Control cmd

LCD_WR_DATA8(0x64);

LCD_WR_DATA8(0x03);

LCD_WR_DATA8(0X12);

LCD_WR_DATA8(0X81);

LCD_WR_REG (0xF7); // Pumb ratio control cmd

LCD_WR_DATA8(0x20);

LCD_WR_REG (0xC0); // Power control 1 cmd

LCD_WR_DATA8(0x23); // VRH[5:0]

LCD_WR_REG (0xC1); // Power control 2 cmd

LCD_WR_DATA8(0x10); // SAP[2:0];BT[3:0]

LCD_WR_REG (0xC5); // VCM control cmd

LCD_WR_DATA8(0x3E);

LCD_WR_DATA8(0x28);

LCD_WR_REG (0xC7); // VCM control2 cmd

LCD_WR_DATA8(0x86);

LCD_WR_REG (0x36); // Memory Access Control cmd

LCD_WR_DATA8(0x48); // parameter 1 (RGB/BGR)


LCD_WR_REG (0x3A);

LCD_WR_DATA8(0x55);

LCD_WR_REG (0xB1);

LCD_WR_DATA8(0x00);

LCD_WR_DATA8(0x18);


LCD_WR_REG (0xB6); // Display Function Control cmd

LCD_WR_DATA8(0x08);

LCD_WR_DATA8(0x82);

LCD_WR_DATA8(0x27);

LCD_WR_REG (0xF2); // 3 Gamma Function Disable cmd

LCD_WR_DATA8(0x00);


LCD_WR_REG (0x26); // Gamma Set cmd

LCD_WR_DATA8(0x01); // Gamma curve 1


LCD_WR_REG (0xE0); //Set Gamma cmd

LCD_WR_DATA8(0x0F);

LCD_WR_DATA8(0x31);

LCD_WR_DATA8(0x2B);

LCD_WR_DATA8(0x0C);

LCD_WR_DATA8(0x0E);

LCD_WR_DATA8(0x08);

LCD_WR_DATA8(0x4E);

LCD_WR_DATA8(0xF1);

LCD_WR_DATA8(0x37);

LCD_WR_DATA8(0x07);

LCD_WR_DATA8(0x10);

LCD_WR_DATA8(0x03);

LCD_WR_DATA8(0x0E);

LCD_WR_DATA8(0x09);

LCD_WR_DATA8(0x00);


LCD_WR_REG (0XE1); //Set Gamma cmd

LCD_WR_DATA8(0x00);

LCD_WR_DATA8(0x0E);

LCD_WR_DATA8(0x14);

LCD_WR_DATA8(0x03);

LCD_WR_DATA8(0x11);

LCD_WR_DATA8(0x07);

LCD_WR_DATA8(0x31);

LCD_WR_DATA8(0xC1);

LCD_WR_DATA8(0x48);

LCD_WR_DATA8(0x08);

LCD_WR_DATA8(0x0F);

LCD_WR_DATA8(0x0C);

LCD_WR_DATA8(0x31);

LCD_WR_DATA8(0x36);

LCD_WR_DATA8(0x0F);


LCD_WR_REG (0xF6); // Interface Control cmd

LCD_WR_DATA8(0x01);

LCD_WR_DATA8(0x20);


LCD_WR_REG (0x11); // Exit Sleep cmd

delayms(120);


LCD_WR_REG (0x29); // Display on cmd

LCD_WR_REG (0x2c); // Memory Write cmd

}


void Show_Image()

{

int i=0,j,k;

Address_set(0,0,239,319); // Full scale addressing

for(k=0;k<320;k++)

{

for(j=0;j<240;j++)

{

LCD_WR_DATA(Image[j+(i*240)]);

}

i++;

}

}