Hi,
Hi, I'm interfacing GLCD with PIC 18LF2520, Oscillator type: Internal 1Mhz, CCS C compiler, GLCD: Winstar WG12232A-YYH.
I'm having difficult in initializing the Graphic lcd. To simulate in proteus, i use AGM1232G graphic display. Below is the sample code. But its not working. Please help,
Hi, I'm interfacing GLCD with PIC 18LF2520, Oscillator type: Internal 1Mhz, CCS C compiler, GLCD: Winstar WG12232A-YYH.
I'm having difficult in initializing the Graphic lcd. To simulate in proteus, i use AGM1232G graphic display. Below is the sample code. But its not working. Please help,
Rich (BB code):
#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
const unsigned char data[] = {0x00, 0x00, 0xE7, 0xE7, 0xE7, 0xE7, 0x00, 0x00}; // invert of H
// Function definitions
void glcd_data(unsigned char z);
void glcd_cmd(unsigned char c);
unsigned int i;
void main()
{
output_high(CS1); // CS1 = 1
output_high(CS2); // CS2 = 1
output_high(RST); // RESET = 1
output_low(R_W); // Write mode
glcd_cmd(0xe2); //software Reset
glcd_cmd(0xAF);
glcd_cmd(0xc0); //Set Start Line 0(C0H)~31(DFH)
glcd_cmd(0xa4); //Static Drive OFF
glcd_cmd(0xa9); //Select Duty = 1 /32
glcd_cmd(0xa0); //Select ADC = 0
glcd_cmd(0xEE);
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
while(1)
{
glcd_cmd(0xC0); // display start line
glcd_cmd(0xB8); // Page address
for (i = 0; i < 8; i++)
{
glcd_data(data); // Display the data on GLCD
}
}
}
void glcd_cmd(unsigned char c)
{
output_low(A0); // Command mode
output_high(CS1);
output_high(CS2);
output_a(c); //
output_low(CS1);
output_low(CS2);
}
void glcd_data(unsigned char z)
{
output_high(A0); // Data mode
output_high(CS1);
output_high(CS2);
output_a(z); //
output_low(CS1);
output_low(CS2);
}