Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfacing 128x64 lcd with PIC16f877a

Status
Not open for further replies.

jou_c

Newbie level 3
Joined
Jun 25, 2009
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,420
hi, i'm trying to interface a 128x64 lcd by Lascar (SP 5-FDX1) with a PIC16f877a. can anyone tell me if this is possible by just using the PIC16f877a or do i need other ICs? the LCD comes with a SPLC 501C controller by SUNPLUS.... sorry i am new in this and haven't much idea how it all works...
 

sorry, i just realise the i misname the lcd model... it's SP 5-gfx1 by lascar.... help anybody???

i've written a code based on the program i found from a website by ian frose, but not a single dot can be displayed!

i'm not sure wat's the matter... i'm using ccs compiler

#include <16f877.h>
#use delay(clock = 4000000)

//sunplus SPLC501C constants
#define page_base 0xb0
#define column_base_l 0x00
#define column_base_h 0x10

//port definition--> all pins are outputs
#define AOP PIN_B3 //determines if databits are data or command. H=data,L=command
#define reset PIN_E2 //setting is initialized when reset = 0
#define SI PIN_D7 //serial data input terminal
#define SCL PIN_D6 //serial clock input terminal
#define button PIN_B0

//#define data_eeprom 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00;
char ADCON1;
int RBPU;
void command_write();
void data_write();
void write_posn();
void write_next();
void clear_page();
void start_up();
void start_posn();

void serial_output(unsigned char x)
{
signed char i;

for(i=7;i>=0;i--)
{
if((x>>i)&0x01)
{
output_high(SI);
}
else
{
output_low(SI);
}
output_low(SCL);
output_high(SCL);
}
}

//write command: page and column address
void command_write(unsigned char data1)
{
output_low(AOP);
serial_output(data1);
}

//write display data
void data_write(unsigned char data2)
{
output_high(AOP);
serial_output(data2);
}


//write display data into desired position.
//parameters: page, column, data

void write_posn(unsigned char page, unsigned char column, unsigned char data)
{
command_write(page_base + (page));
command_write(column_base_h + ((column & 0xf0) >> 4));
command_write(column_base_l + (column & 0x0f));
data_write(data);
}


//write to next location --> used only after a known write position;

void write_next(unsigned char data3)
{
data_write(data3);
}


//to clear ONE page of display (for pages 0-7)

void clear_page(unsigned char page2clear)
{
unsigned char i;
write_posn(page2clear,0x00,0x00); //(page,column,data)
for(i=0;i<128;i++)
{
write_next(0x00);
}
}

//to clear ALL pages of display => clear screen
void clear_all(void)
{
unsigned char i;
for(i=0;i<8;i++)
{
clear_page(i);
}
}


//initialization of 16f877 i/o and splc501c

void start_up(void)
{
output_low(AOP);
output_high(reset);

//reset
output_low(reset); //minimum required time by splc501c is 0.5us
#asm
nop //using 16f877@4Mhz, nop takes 1us!!! CHECK THIS
#endasm
output_low(reset);

//initialization settings. refer 6.xx section of SPLC501c datasheet
command_write(0xA2); //[6.11] LCD bias set: 1/9 bias
command_write(0xA4); //[6.10] Normal display mode -->double check this!
command_write(0xC8); //[6.15] common output mode: reverse com63-com0
command_write(0x23); //[6.17] v5 voltage reg internal
command_write(0x81); //electronic volumn double (brighness control) [6.18]
command_write(read_eeprom(0x00)); //internal pic eeprom at address 0x00.
//default data is 0x1f.
//adjustable in main code from 0x00-0x3f
//then stored back into EEPROM
command_write(0x2b); //[6.16] power control circuit: vol_regON, vol_follwerON, boosterOFF
command_write(0x40); //[6.2] display start line set: line address 0
command_write(page_base); //[6.3] page address set :page address 0
command_write(column_base_h); //[6.4] upper bit column address:1
command_write(column_base_l); //[6.4] lower bit column address:0
//column address = 0
command_write(0xaf); //[6.1] display ON
}


//set start position
void start_posn (unsigned char start_column, unsigned char start_page)
{
command_write(page_base + (start_page));
command_write(column_base_h + ((start_column & 0xf0)>>4));
command_write(column_base_l + (start_column & 0x0f));
}


static const unsigned char tablec [] = {

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // !
// 0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // "
// 0x80,0x00,0x90,0x0C,0xD0,0x03,0xBC,0x00,0x93,0x0C,0xD0,0x03,0xBC,0x00,0x93,0x00,0x90,0x00,0x00,0x00, // #
// 0x00,0x00,0x00,0x00,0x0E,0x0C,0x13,0x08,0x21,0x08,0xFF,0x1F,0xC1,0x08,0x81,0x07,0x00,0x00,0x00,0x00, // $
// 0x0E,0x08,0x11,0x04,0x11,0x02,0x91,0x01,0x4E,0x00,0x20,0x07,0x98,0x08,0x84,0x08,0x82,0x08,0x01,0x07, // %
// 0x80,0x03,0x40,0x04,0x2E,0x08,0x31,0x08,0xD1,0x08,0x99,0x09,0x0E,0x0E,0x00,0x0C,0x00,0x0B,0xC0,0x00, // &
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // '
// 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x03,0x0C,0x0C,0x06,0x18,0x02,0x10,0x01,0x20,0x01,0x20,0x00,0x00, // (
// 0x00,0x00,0x01,0x20,0x01,0x20,0x02,0x10,0x06,0x18,0x0C,0x0C,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, // )
// 0x00,0x00,0x04,0x00,0x0C,0x00,0x78,0x00,0x27,0x00,0x78,0x00,0x0C,0x00,0x04,0x00,0x00,0x00,0x00,0x00, // *
// 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xF0,0x0F,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00, // +
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4C,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ,
0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00, // -
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .
// 0x00,0x00,0x00,0x20,0x00,0x18,0x00,0x06,0x80,0x01,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x00,0x00,0x00, // /
// 0x00,0x00,0xF8,0x01,0x06,0x06,0x01,0x08,0x01,0x08,0x01,0x08,0x06,0x06,0xF8,0x01,0x00,0x00,0x00,0x00, // 0
// 0x00,0x00,0x02,0x08,0x02,0x08,0x02,0x08,0xFF,0x0F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00, // 1
0x00,0x00,0x03,0x0C,0x01,0x0A,0x01,0x09,0x81,0x08,0x61,0x08,0x1E,0x08,0x00,0x00,0x00,0x00,0x00,0x00, // 2
// 0x00,0x00,0x00,0x00,0x01,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0xDE,0x07,0x00,0x00,0x00,0x00,0x00,0x00, // 3
// 0x80,0x01,0x60,0x01,0x10,0x01,0x0C,0x01,0x02,0x01,0xFF,0x0F,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00, // 4
0x00,0x00,0x00,0x00,0x1F,0x08,0x11,0x08,0x11,0x08,0x21,0x04,0xC1,0x03,0x00,0x00,0x00,0x00,0x00,0x00, // 5
0x00,0x00,0xF8,0x03,0x26,0x04,0x11,0x08,0x11,0x08,0x11,0x08,0x21,0x04,0xC0,0x03,0x00,0x00,0x00,0x00, // 6
// 0x00,0x00,0x01,0x00,0x01,0x0C,0x81,0x03,0x61,0x00,0x19,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x00,0x00, // 7
// 0x00,0x00,0x8E,0x07,0x51,0x08,0x21,0x08,0x21,0x08,0x51,0x08,0xD1,0x04,0x0E,0x03,0x00,0x00,0x00,0x00, // 8
// 0x00,0x00,0x3C,0x00,0x42,0x08,0x81,0x08,0x81,0x08,0x81,0x08,0x42,0x06,0xFC,0x01,0x00,0x00,0x00,0x00, // 9
// 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0C,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // :
// 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x4C,0x30,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ;
// 0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x40,0x02,0x40,0x02,0x20,0x04,0x20,0x04,0x10,0x08,0x00,0x00, // <
// 0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00, // =
// 0x00,0x00,0x10,0x08,0x20,0x04,0x20,0x04,0x40,0x02,0x40,0x02,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00, // >
// 0x00,0x00,0x07,0x00,0x01,0x00,0x81,0x0D,0x41,0x00,0x21,0x00,0x13,0x00,0x0E,0x00,0x00,0x00,0x00,0x00, // ?
// 0xF8,0x01,0x0C,0x06,0x02,0x0C,0xF1,0x09,0x09,0x0A,0x05,0x0B,0xC5,0x0D,0xFE,0x03,0x00,0x02,0x00,0x02, // @
0x00,0x08,0x00,0x07,0xC0,0x01,0x38,0x01,0x0C,0x01,0x18,0x01,0x60,0x01,0x80,0x01,0x00,0x06,0x00,0x08, // A
0x00,0x00,0xFC,0x0F,0x44,0x08,0x44,0x08,0x44,0x08,0x44,0x08,0xA4,0x08,0x18,0x07,0x00,0x00,0x00,0x00, // B
0xE0,0x01,0x18,0x06,0x08,0x04,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x0C,0x08,0x00,0x00,0x00,0x00, // C
0x00,0x00,0xFC,0x0F,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x08,0x04,0xF0,0x03,0x00,0x00,0x00,0x00, // D
0x00,0x00,0xFC,0x0F,0x84,0x08,0x84,0x08,0x84,0x08,0x84,0x08,0x84,0x08,0x04,0x08,0x00,0x00,0x00,0x00, // E
0x00,0x00,0xFC,0x0F,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x04,0x00,0x00,0x00,0x00,0x00, // F
0x00,0x00,0xE0,0x01,0x18,0x06,0x08,0x04,0x04,0x08,0x04,0x08,0x84,0x08,0x84,0x08,0x8C,0x0F,0x00,0x00, // G
0x00,0x00,0xFC,0x0F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x0F,0x00,0x00,0x00,0x00, // H
0x00,0x00,0x04,0x08,0x04,0x08,0x04,0x08,0xFC,0x0F,0x04,0x08,0x04,0x08,0x04,0x08,0x00,0x00,0x00,0x00, // I
0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00, // J
0x00,0x00,0xFC,0x0F,0x40,0x00,0xC0,0x00,0x20,0x01,0x10,0x02,0x08,0x02,0x04,0x04,0x00,0x08,0x00,0x00, // K
0x00,0x00,0xFC,0x0F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00, // L
0xFC,0x0F,0x1C,0x00,0xF0,0x00,0x80,0x03,0x00,0x03,0xE0,0x00,0x1C,0x00,0xFC,0x0F,0x00,0x00,0x00,0x00, // M
0x00,0x00,0xFC,0x0F,0x08,0x00,0x30,0x00,0xC0,0x00,0x00,0x03,0x00,0x04,0xFC,0x0F,0x00,0x00,0x00,0x00, // N
0x00,0x00,0xF0,0x03,0x08,0x04,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x08,0x04,0xF0,0x03,0x00,0x00, // O
0x00,0x00,0xFC,0x0F,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00, // P
0x00,0x00,0xF0,0x03,0x08,0x04,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x18,0x08,0x24,0xF0,0x23,0x00,0x00, // Q
0x00,0x00,0xFC,0x0F,0x84,0x00,0x84,0x00,0x84,0x01,0x44,0x02,0x38,0x04,0x00,0x08,0x00,0x00,0x00,0x00, // R
0x00,0x00,0x38,0x0C,0x24,0x08,0x44,0x08,0x44,0x08,0x84,0x08,0x84,0x04,0x0C,0x07,0x00,0x00,0x00,0x00, // S
0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0xFC,0x0F,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00, // T
0x00,0x00,0xFC,0x03,0x00,0x0C,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x04,0xFC,0x03,0x00,0x00,0x00,0x00, // U
0x04,0x00,0x18,0x00,0xE0,0x00,0x00,0x03,0x00,0x0C,0x00,0x0C,0x80,0x03,0x60,0x00,0x18,0x00,0x04,0x00, // V
0x0C,0x00,0xF0,0x01,0x00,0x0E,0x80,0x07,0x70,0x00,0xE0,0x00,0x00,0x07,0x00,0x0E,0xF0,0x01,0x0C,0x00, // W
0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0xC0,0x00,0xC0,0x00,0x20,0x01,0x10,0x02,0x08,0x04,0x04,0x08, // X
0x04,0x00,0x08,0x00,0x30,0x00,0x40,0x00,0x80,0x0F,0x40,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x04,0x00, // Y
0x00,0x00,0x04,0x0C,0x04,0x0A,0x04,0x09,0x84,0x08,0x44,0x08,0x24,0x08,0x14,0x08,0x0C,0x08,0x00,0x00, // Z
// 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x3F,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x00,0x00,0x00,0x00, // [
// 0x00,0x00,0x01,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x80,0x01,0x00,0x06,0x00,0x18,0x00,0x20,0x00,0x00, // \
// 0x00,0x00,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0xFF,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ]
// 0x00,0x00,0x00,0x02,0x80,0x01,0x70,0x00,0x1C,0x00,0x07,0x00,0x38,0x00,0xC0,0x01,0x00,0x02,0x00,0x00, // ^
// 0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10, // _
// 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // `
0x00,0x00,0x00,0x06,0x10,0x09,0x90,0x08,0x90,0x08,0x90,0x04,0xE0,0x0F,0x00,0x08,0x00,0x00,0x00,0x00, // a
0x00,0x00,0xFF,0x0F,0x20,0x04,0x10,0x08,0x10,0x08,0x10,0x08,0x30,0x04,0xC0,0x03,0x00,0x00,0x00,0x00, // b
0x00,0x00,0xC0,0x03,0x20,0x04,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x00,0x00,0x00,0x00, // c
0x00,0x00,0xC0,0x03,0x20,0x0C,0x10,0x08,0x10,0x08,0x10,0x08,0x20,0x04,0xFF,0x0F,0x00,0x00,0x00,0x00, // d
0x00,0x00,0xC0,0x03,0xA0,0x04,0x90,0x08,0x90,0x08,0x90,0x08,0x90,0x08,0xE0,0x08,0x00,0x00,0x00,0x00, // e
0x00,0x00,0x10,0x00,0x10,0x00,0xFE,0x0F,0x12,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x11,0x00,0x00,0x00, // f
0x00,0x00,0xC0,0x03,0x20,0x4C,0x10,0x48,0x10,0x48,0x10,0x48,0x20,0x24,0xF0,0x1F,0x00,0x00,0x00,0x00, // g
0x00,0x00,0xFF,0x0F,0x40,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0xE0,0x0F,0x00,0x00,0x00,0x00, // h
0x00,0x00,0x10,0x00,0x10,0x00,0x13,0x00,0xF3,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // i
0x00,0x00,0x00,0x40,0x10,0x40,0x10,0x40,0x13,0x40,0xF3,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // j
0x00,0x00,0xFF,0x0F,0x80,0x00,0x80,0x01,0x40,0x02,0x20,0x02,0x20,0x04,0x10,0x08,0x00,0x00,0x00,0x00, // k
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // l
0xF0,0x0F,0x20,0x00,0x10,0x00,0x10,0x00,0xE0,0x0F,0x20,0x00,0x10,0x00,0x10,0x00,0xE0,0x0F,0x00,0x00, // m
0x00,0x00,0xF0,0x0F,0x60,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0xE0,0x0F,0x00,0x00,0x00,0x00, // n
0x00,0x00,0xC0,0x03,0x20,0x04,0x10,0x08,0x10,0x08,0x10,0x08,0x20,0x04,0xC0,0x03,0x00,0x00,0x00,0x00, // o
0x00,0x00,0xF0,0x7F,0x20,0x04,0x10,0x08,0x10,0x08,0x10,0x08,0x30,0x04,0xC0,0x03,0x00,0x00,0x00,0x00, // p
0x00,0x00,0xC0,0x03,0x20,0x0C,0x10,0x08,0x10,0x08,0x10,0x08,0x20,0x04,0xF0,0x7F,0x00,0x00,0x00,0x00, // q
0x00,0x00,0x00,0x00,0xF0,0x0F,0x40,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x70,0x00,0x00,0x00,0x00,0x00, // r
0x00,0x00,0x60,0x0C,0x90,0x08,0x90,0x08,0x10,0x09,0x10,0x09,0x10,0x06,0x00,0x00,0x00,0x00,0x00,0x00, // s
0x00,0x00,0x10,0x00,0x10,0x00,0xFC,0x07,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x00,0x00,0x00,0x00, // t
0x00,0x00,0xF0,0x07,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x04,0xF0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00, // u
0x10,0x00,0xE0,0x00,0x00,0x03,0x00,0x0C,0x00,0x08,0x00,0x06,0x80,0x01,0x60,0x00,0x10,0x00,0x00,0x00, // v
0x30,0x00,0xC0,0x03,0x00,0x0C,0x00,0x07,0xE0,0x00,0xC0,0x00,0x00,0x07,0x00,0x0C,0xC0,0x03,0x30,0x00, // w
0x00,0x00,0x10,0x08,0x20,0x04,0x40,0x02,0x80,0x01,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x00,0x00, // x
0x10,0x40,0x60,0x40,0x80,0x41,0x00,0x23,0x00,0x1C,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x10,0x00, // y
0x00,0x00,0x10,0x08,0x10,0x0C,0x10,0x0A,0x10,0x09,0x90,0x08,0x50,0x08,0x30,0x08,0x10,0x08,0x00,0x00, // z
0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x7E,0x1F,0x01,0x20,0x01,0x20,0x01,0x20,0x00,0x00,0x00,0x00, // {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // |
0x00,0x00,0x00,0x00,0x01,0x20,0x01,0x20,0x01,0x20,0x7E,0x1F,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00, // }
0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x21,0x00,0x21,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00}; // º MOD

// Characters are constructed from 20 bytes. The first page bytes are at location 0, 2, 4 etc while
// the second page are at 1, 3, 5 etc. ASCII character 32 is the first entry in the look-up table.
// The table has characters 32 - 127 enabled and 128 to 255 commented out.
// Character 127 has been modified to degrees (normally 176) to allow temperature to be displayed
// Characters can be modified limited depending on space availability. On a project with limited
// memory then this table could be stored in EEPROM

unsigned char display_data (unsigned char page, unsigned char column, unsigned char x)
{
unsigned char lookup, i;
int position;
if (x >= 32)
{
x = x-32; //ASCII 32 is the first character in the lookup table
position = x * 20; //starting index--> ASCII 70 starts at 760
start_posn (column, page); //position = starting index of character = rowNumber*20columns
for (i=0; i<20; i+=2) //x = row axis
{ //i = column axis
lookup = tablec[(position+i)]; //lookup character for 1st page
write_next(lookup);
}
start_posn (column, page+1);
for (i=1;i<20;i+=2);
{
lookup = tablec[(position+i)]; //lookup character for second page
write_next(lookup); //one character is 10 columns wide and 2 pages long
}
}
return 10; //this may be removed to make space
}


void main(void)
{
unsigned char column, page, c, column_num,i,vol;
ADCON1 = 0x84;
start_up();
set_TRIS_B(0xff);
RBPU = 0;
clear_all();

// Setup display contrast, this stays on for about 16s. To cycle through the
// values connect Pin RB0 to 0V, RBO is pulled up internally. The last setting
// is saved into the PIC 16F877 internal EEPROM.

c = display_data (0,24, ('W'));
c = display_data (0,34, ('e'));
c = display_data (0,44, ('l'));
c = display_data (0,54, ('c'));
c = display_data (0,64, ('o'));
c = display_data (0,74, ('m'));
c = display_data (0,84, ('e'));
c = display_data (0,94, (' '));
c = display_data (0,104,('2'));
c = display_data (2,44, ('X'));
c = display_data (2,54, ('Y'));
c = display_data (2,64, ('T'));
c = display_data (2,74, ('E'));
c = display_data (2,84, ('C'));
c = display_data (4,24, ('S'));
c = display_data (4,34, ('O'));
c = display_data (4,44, ('L'));
c = display_data (4,54, ('U'));
c = display_data (4,64, ('T'));
c = display_data (4,74, ('I'));
c = display_data (4,84, ('O'));
c = display_data (4,94, ('N'));
c = display_data (4,104,('S'));
c = display_data (6,4, ('K'));
c = display_data (6,14, ('u'));
c = display_data (6,24, ('l'));
c = display_data (6,34, ('i'));
c = display_data (6,44, ('m'));
c = display_data (6,54, (' '));
c = display_data (6,64, ('H'));
c = display_data (6,74, ('i'));
c = display_data (6,84, ('-'));
c = display_data (6,94, ('T'));
c = display_data (6,104, ('e'));
c = display_data (6,114, ('c'));

vol = read_eeprom(0x00);
for (i=0;i<63;i++)
{
if(input(button))
{
delay_ms(50);
if (input(button))
{
vol++;
if (vol > 0x3f) vol = 0x00;
command_write(0x81); //volumn control double->brigtness control
command_write(vol); //command_write (read_eeprom(0x00))
}
}
delay_ms(250);
}

// Creates a demo with each character between ASCII 32 & 127 being displayed
// The display shows 12 characters per line and after 4 lines the display is
// cleared and restarts on the first line

while(1)
{
clear_all();
column = 0;
page = 0;
for(i=0x20;i<0x7f;i++)
{
if(column > 118)
{
column = 0;
page = page+2;
if (page > 7)
{
page = 0;
clear_all();
}
}
column_num = display_data(page,column,i);
column = column + column_num;
delay_ms(150);
}
}



}
 


hi, i've read through all the websites, but it's still not working
any other ideas?
 

hi, i am trying to do a menu selection hand held device by using graphical LCD 128x64 with PIC16F877A. The coding program i using is ccs c compiler. Since i am new in this, i am only able to display characters and i have no idea how to program a selection menu...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top