#include "18F2520.h"
#fuses INTRC_IO // Internal oscillator
#use delay(clock = 1000000) // 1Mhz clock
// PIN Definitions
#define A0 PIN_B3
#define CS1 PIN_B4
#define CS2 PIN_B5
#define R_W PIN_C0
#define RST PIN_C1
void GLCD_INIT();
void glcd_cmd(unsigned char c);
void glcd_data(unsigned char z);
const unsigned char data[] = {0xFF, 0xFF, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF};
const unsigned char space[] = {0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00};
void main()
{
unsigned int i,j,k;
GLCD_INIT();
k = 0;
for(k = 0; k < 4; k++)
{
glcd_cmd(0xB8 + k);
for(j = 0; j < 64; j = j+8)
{
glcd_cmd(0 + j);
for(i = 0; i < 8; i++)
{
glcd_data(space[i]);
}
}
}
while(1)
{
glcd_cmd(0xc0);
glcd_cmd(0xb8);
glcd_cmd(0);
i = 0;
for (i = 0; i < 8; i++)
{
glcd_data1(data[i]);
}
}
}
void GLCD_INIT()
{
output_high(RST); // RESET = 1
glcd_cmd(0xe2); //software Reset
glcd_cmd(0xa0); //Select ADC = 0
glcd_cmd(0xa4); //Static Drive OFF
glcd_cmd(0xa9); //Select Duty = 1 /32
glcd_cmd(0xc0); //Set Start Line 0(C0H)~31(DFH)
glcd_cmd(0xb8); //Set Page Address 0(B8H)~3(BBH)
glcd_cmd(0x00); //Set segment Address 0(00H)~(4FH)
glcd_cmd(0xaf); //Set Display ON
}
void glcd_cmd(unsigned char c)
{
output_low(A0);
output_low(R_W);
output_a(c);
output_high(CS1);
output_high(CS2);
output_low(CS1);
output_low(CS2);
}
void glcd_data(unsigned char z)
{
output_high(A0);
output_low(R_W);
output_a(z);
output_high(CS1);
output_high(CS2);
output_low(CS1);
output_low(CS2);
}