The transmission is an 8-bit and the display is a 5-inch 800x480.
The display still works, it displays a white screen.
#include "mbed.h"
#include "stdlib.h"
#include "string.h"
//---------------------------------------------------------
unsigned char command;
unsigned char data1;
int DOWN;
int RIGHT;
//---------------------------------------------------------
//DigitalOut RS(p14); /* reset to SSD1963 */
DigitalOut nWR(p15); /* write out to SSD1963 active LOW */
DigitalOut nRD(p16); /* read data from SSD1963 active LOW */
DigitalOut CS(p13); /* chip select the SSD1963 active LOW */
DigitalOut DC(p17); /* Data/Command Select: 1=Command, 0=Data); */
DigitalOut myled(LED1); /* for test purposes only */
/* data bus I/O pins */
Serial pc(p28,p27);
//BusInOut DB(p12,p11,p10,p9,p8,p7,p6,p5); /* databus D0-D7 */
BusInOut DB(p5,p6,p7,p8,p9,p10,p11,p12); /* databus D0-D7 */
/*Following are HARD WIRED on the controller board */
//DigitalIn DOWN = P3^6;
//sbit RIGHT = P3^2;
//******************************************************************************
void Write_Command(unsigned char command) {
nRD = 1; /* make sure the RD is HIGH just to be sure */
DC=1;
nWR = 0;
CS=0;
wait_us(1);
DB=command;
DB.write(command);
//DB=command;
wait_us(1);
nWR = 1;
CS = 1;
}
//;******************************************************************************
void Write_Data(unsigned char data1) {
nRD = 1;
DC=0;
nWR = 0;
CS=0;
wait_us(1);
DB=data1;
DB.write(data1);
//DB=data1;
wait_us(1);
nWR = 1;
CS = 1;
}
//====================================================
void Command_Write(unsigned char REG,unsigned char VALUE) {
Write_Command(REG);
Write_Data(VALUE);
}
//======================================================
void SendData(unsigned long color) {
Write_Data((color)>>16); //red
Write_Data((color)>>8); //green
Write_Data(color); //blue
}
//======================================================
// initialize controller
//======================================================
void Init_SSD1963 (void) {
pc.printf("Start init \n");
//RESET = 0;
wait_ms(5);
//RESET = 1;
//myled-!myled;
DOWN = 0;
RIGHT = 1;
wait_ms(100);
Write_Command(0x01); //Software Reset
wait_ms(100);
Write_Command(0x01);
Write_Command(0x01);
wait_ms(10);
Command_Write(0xe0,0x01); //START PLL
Command_Write(0xe0,0x03); //LOCK PLL
Write_Command(0xb0); //LCD specification
Write_Data(0x20); //SET TFT MODE & hsync+Vsync+DEN MODE
Write_Data(0x00); //SET TFT MODE & hsync+Vsync+DEN MODE
Write_Data(0x03); //SET horizontal size=800-1 HightByte
Write_Data(0x1f); //SET horizontal size=800-1 LowByte
Write_Data(0x01); //SET vertical size=480-1 HightByte
Write_Data(0xdf); //SET vertical size=480-1 LowByte
Write_Data(0x00); //SET even/odd line RGB seq.=RGB
wait_ms(5);
Command_Write(0xf0,0x00); //SET pixel data I/F format=8bit
//Command_Write(0x3a,0x60); // SET R G B format = 6 6 6
Write_Command(0xe6); //PLL setting for PCLK, depends on resolution
Write_Data(0x00);
Write_Data(0xff);
Write_Data(0xbe);
Write_Command(0xb4); //SET HBP,
Write_Data(0x03); //SET HSYNC Total=928 HightByte
Write_Data(0xa0); //SET HSYNC Total=928 LowByte
Write_Data(0x00); //SET HBP 46 HightByte
Write_Data(0x2e); //SET HBP 46 LowByte
Write_Data(0x30); //SET VBP 48
Write_Data(0x00); //SET Hsync pulse start position (15 HighByte)
Write_Data(0x0f); //15 LowByte
Write_Data(0x00); //SET Hsync pulse subpixel start position
Write_Command(0xb6); //SET VBP,
Write_Data(0x02); //SET Vsync total=525 HighByte
Write_Data(0x0d); // 525 LowByte
Write_Data(0x00); //SET VBP=16 HighByte
Write_Data(0x10); // 16 LowByte
Write_Data(0x10); //SET Vsync pulse 16
Write_Data(0x00); //SET Vsync pulse start position (8 HighByte)
Write_Data(0x08); //8 LowByte
/*Write_Command(0x2a); //SET column address
Write_Data(0x00); //SET start column address=0
Write_Data(0x00);
Write_Data(0x03); //SET end column address=639
Write_Data(0x1f);*/
/*Write_Command(0x2b); //SET page address
Write_Data(0x00); //SET start page address=0
Write_Data(0x00);
Write_Data(0x01); //SET end page address=479
Write_Data(0xdf);*/
Command_Write(0x36,0x00); //Rotation
Write_Command(0x29); //SET display on
Write_Command(0x00be); //SET PWM for B/L
Write_Data(0x0006);
Write_Data(0x00f0);
Write_Data(0x0001);
Write_Data(0x00f0);
Write_Data(0x0000);
Write_Data(0x0000);
Write_Command(0x00d0);
Write_Data(0x000d);
//Reset GPIO0
Write_Command(0x00b8);
Write_Data(0x0000);
Write_Data(0x0001);
Write_Command(0x00ba);
Write_Data(0x0000);
pc.printf("End init \n");
}
//======================================================
void WindowSet(unsigned int s_x,unsigned int e_x,unsigned int s_y,unsigned int e_y) {
Write_Command(0x2a); //SET page address
Write_Data((s_x)>>8); //SET start page address=0
Write_Data(s_x&0x00ff);
Write_Data((e_x)>>8); //SET end page address=639
Write_Data(e_x&0x00ff);
Write_Command(0x2b); //SET column address
Write_Data((s_y)>>8); //SET start column address=0
Write_Data(s_y&0x00ff);
Write_Data((e_y)>>8); //SET end column address=479
Write_Data(e_y&0x00ff);
}
//=======================================
void FULL_ON(unsigned long dat) {
unsigned char x,y;
WindowSet(0x0000,0x031f,0x0000,0x01df);
Write_Command(0x2c);
for (x=0;x<480;x++) {
for (y= 0;y<800;y++) {
SendData(dat);
pc.printf("x:%n y:%n", x, y);
}
}
}
//=======================================
void QUADS() {
unsigned int i,j;
WindowSet(0x0000,0x031f,0x0000,0x01df);
Write_Command(0x2c);
for (j= 0 ;j<240;j++) {
for (i=0;i<320;i++) {
SendData(0x0000FF); //blue
}
/*for (i=0;i<320;i++) {
SendData(0xFF0000); //red
}*/
}
/*for (j= 0 ;j<240;j++) {
for (i=0;i<320;i++) {
SendData(0xFFFF00); //yellow
}
for (i=0;i<320;i++) {
SendData(0x00FF00); //green
}
}*/
}
//=======================================
int main(void) {
wait_ms(100);
myled=1;
wait_ms(500);
myled=!myled;
wait_ms(500);
myled=!myled;
Init_SSD1963();
while (1) {
pc.printf("CICLO \n");
myled=!myled;
wait_ms(5);
pc.printf("Function: QUADS \n");
QUADS();
//pc.printf("Function: FULL_ON \n");
//FULL_ON(0x0000ff); //blue
myled=!myled;
wait(2);
}
}
Hello everyone .. I bought this display: http://imall.iteadstudio.com/display/tft-lcm/im120419008.html. Which library can I use to make it work with the mbed?.
This display features a SSD1963.
Thanks to all