#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,PLL5,CPUDIV1,VREGEN,NOMCLR,NOPBADEN
/*OSCILLATOR SETUP***********************************************************************************
20MHz crystal, HSPLL enables PLL, PLL5 gives 4MHz (=20/5) input to PLL - PLL output 96MHz (=24*4)
CPUDIV1 gives FOSC = 48MHz (=96/2) - Single word instruction time = 1/(48/4E6) = 83.3ns (83.3E-9 secs)
*****************************************************************************************************/
#use delay(clock=48M)//48000000Hz
#use rs232(baud=4800, xmit=PIN_C6,rcv=PIN_C7, PARITY=N, BITS=8, STOP=1)
//control pins
#define RS PIN_D5
#define WR PIN_D4
#define CS PIN_D3
#define RESET PIN_D2
//8 bit data bus pins
#define DB0 PIN_B5
#define DB1 PIN_B4
#define DB2 PIN_B3
#define DB3 PIN_B2
#define DB4 PIN_B1
#define DB5 PIN_B0
#define DB6 PIN_D7
#define DB7 PIN_D6
//display image
char const image[3200]={
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,0X7D,0XEF,
0XBA,0XD6,0XB6,0XB5,0XF3,0X9C,0XB2,0X94,0XB3,0X9C,0XB2,0X94,0X34,0XA5,0XF7,0XBD,
0XFB,0XDE,0X7D,0XEF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,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,0X41,0X08,
0XC7,0X39,0X08,0X42,0X49,0X4A,0X49,0X4A,0X8A,0X52,0X8A,0X52,0X4A,0X4A,0XD0,0X7B,
0X7A,0XC6,0X7B,0XBE,0X90,0X6B,0XC9,0X39,0X88,0X31,0XC9,0X39,0XB3,0X84,0XBB,0XC6,
0XF8,0XB5,0XCC,0X5A,0X86,0X31,0XC7,0X39,0XC7,0X39,0X86,0X31,0X45,0X29,0X45,0X29,
0XC4,0X20,0X41,0X08,0X30,0X84,0X3C,0XE7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3C,0XE7,0X8A,0X4A,0XC3,0X10,
0XC7,0X39,0X08,0X42,0X49,0X4A,0X49,0X4A,0X4A,0X4A,0X4A,0X42,0X09,0X3A,0X08,0X4A,
0X09,0X6B,0X49,0X7B,0XC6,0X7A,0X05,0X83,0X46,0X83,0XC5,0X7A,0XC6,0X72,0X09,0X7B,
0X48,0X5A,0X87,0X31,0X88,0X21,0X88,0X29,0X86,0X31,0X86,0X31,0X45,0X29,0X45,0X29,
0X04,0X21,0X41,0X08,0X4A,0X4A,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XC5,0X82,0X50,0X05,0X41,
0XC7,0X29,0X08,0X42,0X49,0X4A,0X4A,0X42,0X49,0X4A,0X09,0X7B,0X88,0X9B,0XC6,0XB3,
0X21,0XD4,0XA0,0XDC,0XE1,0XE4,0X61,0XED,0X61,0XED,0X21,0XED,0XA0,0XE4,0X20,0XDC,
0X80,0XCB,0X43,0XAB,0XC4,0X82,0X06,0X5A,0X47,0X21,0X46,0X29,0X45,0X29,0X04,0X29,
0X04,0X19,0X82,0X10,0X82,0X18,0XF3,0X9C,0X7D,0XEF,0XFF,0XFF,0XF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,0X6A,0XC5,0X41,0X45,0X29,0XC3,0X58,0X41,0XA8,
0X40,0X98,0X00,0XB0,0X00,0X60,0X0C,0X6B,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7D,0XEF,0XCE,0X83,0X82,0X88,0X00,0XF8,0XC4,0XD8,
0X0C,0XF3,0X8A,0XFA,0X82,0XE8,0X82,0XB0,0X45,0X69,0XC7,0X51,0X08,0X42,0X08,0X3A,
0X86,0X5A,0X83,0X9B,0XA2,0XBC,0X22,0XCD,0X21,0XCD,0XA1,0XC4,0X22,0XB4,0XC4,0X7A,
0X06,0X3A,0X86,0X29,0X45,0X29,0X05,0X31,0XC4,0X50,0X41,0X90,0X00,0XC0,0X00,0XA8,
0X00,0XA0,0X00,0XA8,0X00,0X30,0X4A,0X4A,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0X7D,0XEF,0X8E,0X73,0XC3,0X18,0X05,0X39,0X82,0XA8,0X00,0XF8,
0XC3,0XF8,0X4D,0XFB,0X4D,0XFB,0XC7,0XF9,0XC3,0XF0,0X82,0XD8,0XC3,0XB0,0X04,0X81,
0X45,0X61,0X46,0X51,0X86,0X49,0X86,0X49,0X46,0X41,0X45,0X41,0X45,0X41,0X45,0X41,
0X05,0X49,0X04,0X61,0X82,0X90,0X41,0XB0,0X00,0XD0,0X00,0XC8,0X00,0XA8,0X00,0XA8,
0X00,0XB8,0X41,0X58,0X82,0X10,0X82,0X10,0XB2,0X94,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XBE,0XF7,0XCF,0X7B,0X82,0X10,0X04,0X21,0X86,0X29,0X86,0X41,0X04,0X99,
0X40,0XE8,0X41,0XF8,0X86,0XF9,0XCB,0XFA,0X49,0XFA,0X82,0XF8,0X00,0XF8,0X00,0XF0,
0X00,0XE8,0X41,0XD8,0X41,0XD0,0X41,0XC0,0X41,0XC0,0X41,0XC0,0X41,0XC0,0X41,0XC8,
0X00,0XD0,0X00,0XE0,0X00,0XE0,0X00,0XD8,0X00,0XD0,0X00,0XB8,0X00,0XA8,0X41,0X88,
0X82,0X48,0X82,0X10,0X82,0X10,0X00,0X00,0X45,0X29,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,
0XBE,0XF7,0XF3,0X9C,0X82,0X10,0XC3,0X18,0X45,0X29,0X86,0X31,0XC7,0X31,0X30,0X7C,
0XF3,0XDC,0X86,0XE1,0X00,0XF0,0X00,0XF8,0X41,0XF8,0X41,0XF8,0X00,0XF8,0X00,0XF8,
0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,
0X00,0XE8,0X00,0XE0,0X00,0XE0,0X00,0XD8,0X00,0XC8,0X41,0XA0,0X8A,0X9A,0X0C,0X63,
0X04,0X11,0X82,0X10,0X82,0X10,0X41,0X08,0X00,0X00,0X4D,0X6B,0X7D,0XEF,0XFF,0XFF,
0XFB,0XDE,0X08,0X42,0X42,0X10,0X45,0X29,0X86,0X31,0X86,0X31,0X49,0X4A,0X38,0XBE,
0XFF,0XFF,0X38,0XD6,0X86,0XA9,0X00,0XC8,0X00,0XE0,0X00,0XF0,0X00,0XF8,0X00,0XF8,
0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF0,0X00,0XF0,
0X00,0XE8,0X00,0XE0,0X00,0XD0,0XC3,0X98,0X8A,0X8A,0XB2,0XA4,0XBA,0XC6,0XF7,0XB5,
0X08,0X42,0X41,0X08,0X82,0X10,0X41,0X08,0X00,0X00,0X45,0X29,0XF7,0XBD,0XFF,0XFF,
0X71,0X8C,0X41,0X08,0X04,0X21,0X45,0X29,0X86,0X31,0X86,0X31,0X0C,0X63,0X3C,0XE7,
0XFF,0XFF,0X79,0XD6,0X46,0XB9,0X00,0XE0,0X42,0X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3,0X9C,
0X35,0XA5,0XF8,0XBD,0XFB,0XDE,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7E,0XEF,
0XBB,0XD6,0XF8,0XBD,0XB6,0XAD,0X75,0XAD,0X34,0XA5,0X33,0X9D,0X34,0X9D,0X35,0XA5,
0XB7,0XAD,0X79,0XC6,0X3C,0XE7,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF
};
//function templates
void LCD_Writ_Bus(char,char);
void LCD_Write_COM(char,char);
void LCD_Write_DATA(char,char);
void Address_set(long, long, long, long);
void LCD_Init(void);
void Pant(char,char);
void SelectDBPin(int, short);
//functions
void SelectDBPin(int index, short HiLo)
{
if (HiLo)
{
switch (index) {
case 0: output_high(DB0);
break;
case 1: output_high(DB1);
break;
case 2: output_high(DB2);
break;
case 3: output_high(DB3);
break;
case 4: output_high(DB4);
break;
case 5: output_high(DB5);
break;
case 6: output_high(DB6);
break;
case 7: output_high(DB7);
break;
default:printf("bad cmd\r\n");
break;
}
}
else
{
switch (index) {
case 0: output_low(DB0);
break;
case 1: output_low(DB1);
break;
case 2: output_low(DB2);
break;
case 3: output_low(DB3);
break;
case 4: output_low(DB4);
break;
case 5: output_low(DB5);
break;
case 6: output_low(DB6);
break;
case 7: output_low(DB7);
break;
default:printf("bad cmd\r\n");
break;
}
}
}
void LCD_Writ_Bus(char VH, char VL)
{
unsigned char temp,data;
int i;
data=VH;//high byte
for(i=0;i<8;i++)
{
temp=(data&0x01);
if(temp)SelectDBPin(i,1);
else SelectDBPin(i,0);
data=data>>1;
}
output_low(WR);
output_high(WR);
data=VL;//low byte
for(i=0;i<8;i++)
{
temp=(data&0x01);
if(temp) SelectDBPin(i,1);
else SelectDBPin(i,0);
data=data>>1;
}
output_low(WR);
output_high(WR);
}
void LCD_Write_COM(char VH, char VL) //send command
{
output_low(RS);
LCD_Writ_Bus(VH,VL);
}
void LCD_Write_DATA(char VH,char VL) //send data
{
output_high(RS);
LCD_Writ_Bus(VH,VL);
}
void Address_set(unsigned long x1, unsigned long y1, unsigned long x2, unsigned long y2)
{
char x1HiByte, x1LoByte, y1HiByte, y1LoByte, x2HiByte, x2LoByte, y2HiByte, y2LoByte;
x1HiByte = (char) x1>>8;
x1LoByte = (char) x1&0x00FF;
y1HiByte = (char) y1>>8;
y1LoByte = (char) y1&0x00FF;
x2HiByte = (char) x2>>8;
x2LoByte = (char) x2&0x00FF;
y2HiByte = (char) y2>>8;
y2LoByte = (char) y2&0x00FF;
LCD_Write_COM(0x00,0x20);
LCD_Write_DATA(x1HiByte,x1LoByte);
LCD_Write_COM(0x00,0x21);
LCD_Write_DATA(y1HiByte,y1LoByte);
LCD_Write_COM(0x00,0x50);
LCD_Write_DATA(x1HiByte,x1LoByte);
LCD_Write_COM(0x00,0x52);
LCD_Write_DATA(y1HiByte,y1LoByte);
LCD_Write_COM(0x00,0x51);
LCD_Write_DATA(x2HiByte,x2LoByte);
LCD_Write_COM(0x00,0x53);
LCD_Write_DATA(y2HiByte,y2LoByte);
LCD_Write_COM(0x00,0x22);
}
void LCD_Init(void)
{
output_high(RESET);
delay_ms(1);
output_low(RESET);
delay_ms(10);
output_high(RESET);
delay_ms(50);
output_low(CS);
//************* Start Initial Sequence **********//
LCD_Write_COM(0x00,0xE5);
LCD_Write_DATA(0x78,0xF0); // set SRAM internal timing
LCD_Write_COM(0x00,0x01);
LCD_Write_DATA(0x01,0x00); // set SS and SM bit
LCD_Write_COM(0x00,0x02);
LCD_Write_DATA(0x07,0x00); // set 1 line inversion
LCD_Write_COM(0x00,0x03);
LCD_Write_DATA(0x10,0x30); // set GRAM write direction and BGR=1.
LCD_Write_COM(0x00,0x04);
LCD_Write_DATA(0x00,0x00); // Resize register
LCD_Write_COM(0x00,0x08);
LCD_Write_DATA(0x02,0x07); // set the back porch and front porch
LCD_Write_COM(0x00,0x09);
LCD_Write_DATA(0x00,0x00); // set non-display area refresh cycle ISC[3:0]
LCD_Write_COM(0x00,0x0A);
LCD_Write_DATA(0x00,0x00); // FMARK function
LCD_Write_COM(0x00,0x0C);
LCD_Write_DATA(0x00,0x00); // RGB interface setting
LCD_Write_COM(0x00,0x0D);
LCD_Write_DATA(0x00,0x00); // Frame marker Position
LCD_Write_COM(0x00,0x0F);
LCD_Write_DATA(0x00,0x00); // RGB interface polarity
//*************Power On sequence ****************//
LCD_Write_COM(0x00,0x10);
LCD_Write_DATA(0x00,0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_Write_COM(0x00,0x11);
LCD_Write_DATA(0x00,0x07); // DC1[2:0], DC0[2:0], VC[2:0]
LCD_Write_COM(0x00,0x12);
LCD_Write_DATA(0x00,0x00); // VREG1OUT voltage
LCD_Write_COM(0x00,0x13);
LCD_Write_DATA(0x00,0x00); // VDV[4:0] for VCOM amplitude
LCD_Write_COM(0x00,0x07);
LCD_Write_DATA(0x00,0x01);
delay_ms(50); // Dis-charge capacitor power voltage
LCD_Write_COM(0x00,0x10);
LCD_Write_DATA(0x10,0x90); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_Write_COM(0x00,0x11);
LCD_Write_DATA(0x02,0x27); // DC1[2:0], DC0[2:0], VC[2:0]
delay_ms(50); // Delay 50ms
LCD_Write_COM(0x00,0x12);
LCD_Write_DATA(0x00,0x1F); //001C// Internal reference voltage= Vci;
delay_ms(50); // Delay 50ms
LCD_Write_COM(0x00,0x13);
LCD_Write_DATA(0x15,0x00); //0x1000//1400 Set VDV[4:0] for VCOM amplitude 1A00
LCD_Write_COM(0x00,0x29);
LCD_Write_DATA(0x00,0x27); //0x0012 //001a Set VCM[5:0] for VCOMH //0x0025 0034
LCD_Write_COM(0x00,0x2B);
LCD_Write_DATA(0x00,0x0D); // Set Frame Rate 000C
delay_ms(50); // Delay 50ms
LCD_Write_COM(0x00,0x20);
LCD_Write_DATA(0x00,0x00); // GRAM horizontal Address
LCD_Write_COM(0x00,0x21);
LCD_Write_DATA(0x00,0x00); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
LCD_Write_COM(0x00,0x30);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x31);
LCD_Write_DATA(0x07,0x07);
LCD_Write_COM(0x00,0x32);
LCD_Write_DATA(0x03,0x07);
LCD_Write_COM(0x00,0x35);
LCD_Write_DATA(0x02,0x00);
LCD_Write_COM(0x00,0x36);
LCD_Write_DATA(0x00,0x08);//0207
LCD_Write_COM(0x00,0x37);
LCD_Write_DATA(0x00,0x04);//0306
LCD_Write_COM(0x00,0x38);
LCD_Write_DATA(0x00,0x00);//0102
LCD_Write_COM(0x00,0x39);
LCD_Write_DATA(0x07,0x07);//0707
LCD_Write_COM(0x00,0x3C);
LCD_Write_DATA(0x00,0x02);//0702
LCD_Write_COM(0x00,0x3D);
LCD_Write_DATA(0x1D,0x04);//1604
//------------------ Set GRAM area ---------------//
LCD_Write_COM(0x00,0x50);
LCD_Write_DATA(0x00,0x00); // Horizontal GRAM Start Address
LCD_Write_COM(0x00,0x51);
LCD_Write_DATA(0x00,0xEF); // Horizontal GRAM End Address
LCD_Write_COM(0x00,0x52);
LCD_Write_DATA(0x00,0x00); // Vertical GRAM Start Address
LCD_Write_COM(0x00,0x53);
LCD_Write_DATA(0x01,0x3F); // Vertical GRAM Start Address
LCD_Write_COM(0x00,0x60);
LCD_Write_DATA(0xA7,0x00); // Gate Scan Line
LCD_Write_COM(0x00,0x61);
LCD_Write_DATA(0x00,0x01); // NDL,VLE, REV
LCD_Write_COM(0x00,0x6A);
LCD_Write_DATA(0x00,0x00); // set scrolling line
//-------------- Partial Display Control ---------//
LCD_Write_COM(0x00,0x80);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x81);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x82);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x83);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x84);
LCD_Write_DATA(0x00,0x00);
LCD_Write_COM(0x00,0x85);
LCD_Write_DATA(0x00,0x00);
//-------------- Panel Control -------------------//
LCD_Write_COM(0x00,0x90);
LCD_Write_DATA(0x00,0x10);
LCD_Write_COM(0x00,0x92);
LCD_Write_DATA(0x06,0x00);
LCD_Write_COM(0x00,0x07);
LCD_Write_DATA(0x01,0x33); // 262K color and display ON
output_high(CS);
}
void Pant(char VH,char VL)
{
int i,j;
output_low(CS);
Address_set(0,0,240,320);
for(i=0;i<320;i++)
{
for (j=0;j<240;j++)
{
LCD_Write_DATA(VH,VL);
}
}
output_high(CS);
}
void main(void)
{
char hi,lo;
unsigned long i, j, k;
set_Tris_B(0x0);
set_Tris_D(0x0);
while(true)
{
LCD_Init();
//Pant(0xff,0xff);
output_low(CS);
for(k=0;k<8;k++)//8
{
for(j=0;j<6;j++)//6
{
Address_set(40*j,40*k,40*j+39,40*k+39);
for(i=0;i<1600;i++)//1600
{
LCD_Write_DATA(image[i*2+1],image[i*2]);
}
}
}
output_high(CS);
delay_ms(3000);
}
}
|