LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Nov 21, 2024 22:20

All times are UTC + 2 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Apr 05, 2010 1:29 
Offline

Joined: Mon Apr 05, 2010 1:08
Posts: 3
Hi.

I was adapted the rotine developed by John P. Beale, write to work with PC parallel port, to work with PIC microcontroler.

Original rotine:

http://www.skippari.net/lcd/controlt6963c_c.txt


Adapted rotine:

/* ----------------------------------------------------------
* Program to control a T6963C-based 240x64 pixel LCD display
* using the Microchip PIC16F648A Microcontroller
* written in CCS C++
*
* Original Written by John P. Beale May 3-4, 1997 beale@best.com
* Adapted by Plínio Branquinho Apr 5, 2010 plinio.branquinho@hotmail.com
*
* Based on information from Steve Lawther,
* "Writing Software for T6963C based Graphic LCDs", 1997 which is at
* http://ourworld.compuserve.com/homepage ... t6963c.pdf
*
* and the Toshiba T6963C data sheet, also on Steve's WWW page
*
* and info at: http://www.citilink.com/~jsampson/lcdindex.htm
* http://www.cs.colostate.edu/~hirsch/LCD.html
* http://www.hantronix.com/
* ----------------------------------------------------------*/

// Pin numbers refer to pins on PIC16F648A.
// Recall that SEL (pin 17), LF (14), and STROBE (1) control ouputs
// are inverted, but Init (16) is true.
//
// LCD pin numbering for TOSHIBA TLX-711A-E0 (uses T6963C controller)
//
// LCD Pin ----- PC Port Pin Status Reg. bit
// ------------------------------------------
// C/D (8) <--> RA1(17) /SEL 3
// /WR (5) <--> RA6(16) Init 2
// /RD (6) <--> RA7(14) /LF 1
// /CE (7) <--> RA0(1) /Strobe 0
// -----------------------
// D0 (11) <--> RB0(2) D0
// D1 (12) <--> RB1(3) D1
// D2 (13) <--> RB2(4) D2
// D3 (14) <--> RB3(5) D3
// D4 (15) <--> RB4(6) D4
// D5 (16) <--> RB5(7) D5
// D6 (17) <--> RB6(8) D6
// D7 (18) <--> RB7(9) D7
// GND (2) <--> GND
// --------------------------------------------------------------
// FG (1) frame ground
// +5V (3) LCD logic supply
// -7.8V (4) LCD display contrast
// FS (19) font select
// RST (10) active low
// --------------------------------------------------------------

#bit CE = 0x05.0 // CE (7) <--> RA0
#bit RD = 0x05.7 // RD (6) <--> RA7
#bit WR = 0x05.6 // WR (5) <--> RA6
#bit CD = 0x05.1 // C/D (8) <--> RA1

/* ----- Definitions concerning LCD internal memory ------ */

#define G_BASE 0x0200 // base address of graphics memory
#define T_BASE 0x0000 // base address of text memory
#define BYTES_PER_ROW 40 // how many bytes per row on screen

/* This will be 30 with 8x8 font, 40 with 6x8 font, for both
Text & Graphics modes. Font selection by FS pin on LCD module:
FS=High: 6x8 font. FS=Low: 8x8 font. */

/* ----------------------------------------------------------- */
#define XMAX 239 // limits of (x,y) LCD graphics drawing
#define XMIN 0
#define YMAX 63
#define YMIN 0

#include <string>

void dput(int dbyte); // write data byte to LCD module
int dget(void); // get data byte from LCD module
int sget(void); // check LCD display status pbrt
void cput(int dbyte); // write command byte to LCD module
void lcd_setup(); // make sure control lines are at correct levels
void lcd_init(); // initialize LCD memory and display modes
void lcd_print(char *string); // send string of characters to LCD
void lcd_clear_graph(); // clear graphics memory of LCD
void lcd_clear_text(); // clear text memory of LCD
void lcd_xy(int x, int y); // set memory pointer to (x,y) position (text)
void lcd_setpixel(int column, int row); // set single pixel in 240x64 array

#define home() dput(T_BASE%256);dput(T_BASE>>8);cput(0x24); // upper-left

void lcd_clear_graph() // clear graphics memory of LCD
{
long int i;

dput(G_BASE%256);
dput(G_BASE>>8);
cput(0x24); // addrptr at address G_BASE

for (i=0;i<2560>>8);
cput(0x24); // addrptr at address T_BASE

for (i=0;i<320;i++) {
dput(0); cput(0xc0); // write data, inc ptr.
} // end for(i)

} // lcd_clear_text()

/* ----------------------------------------------------------- */

void lcd_print(char *string) // send string of characters to LCD
{
int i;
int c;

for (i=0;i<strlen(string);i++) {
c = string[i] - 0x20; // convert ASCII to LCD char address
if (c<0>>8); cput(0x24); // set LCD addr. pointer
cput(0xf8 | (5-(column%6)) ); // set bit-within-byte command

} // end lcd_setpixel()

/* ----------------------------------------------------------- */

void lcd_xy(int x, int y) // set memory pointer to (x,y) position (text)
{
int addr;

addr = T_BASE + (y * BYTES_PER_ROW) + x;
dput(addr%256); dput(addr>>8); cput(0x24); // set LCD addr. pointer

} // lcd_xy()

/* ==============================================================
* Low-level I/O routines to interface to LCD display
* based on four routines:
*
* dput(): write data byte
* cput(): write control byte
* dget(): read data byte (UNTESTED)
* sget(): read status
* ============================================================== */

void lcd_setup() // make sure control lines are at correct levels
{
CE=1; //HI; // disable chip
RD=1; //HI; // disable reading from LCD
WR=1; //HI; // disable writing to LCD
CD=1; //HI; // command/status mode
set_tris_b(0x00); //DATAOUT; // make 8-bit parallel port an output port
} // end lcd_setup()

/* ----------------------------------------------------------- */

void lcd_init() // initialize LCD memory and display modes
{
dput(G_BASE%256);
dput(G_BASE>>8);
cput(0x42); // set graphics memory to address G_BASE

dput(BYTES_PER_ROW%256);
dput(BYTES_PER_ROW>>8);
cput(0x43); // n bytes per graphics line

dput(T_BASE%256);
dput(T_BASE>>8);
cput(0x40); // text memory at address T_BASE

dput(BYTES_PER_ROW%256);
dput(BYTES_PER_ROW>>8);
cput(0x41); // n bytes per text line

cput(0x80); // mode set: Graphics OR Text, ROM CGen

cput(0xa7); // cursor is 8 lines high
dput(0x00);
dput(0x00);
cput(0x21); // put cursor at (x,y) location

cput(0x97); // Graphics & Text ON, cursor blinking
// (For cursor to be visible, need to set up position)

} // end lcd_init()

/* ----------------------------------------------------------- */

int sget(void) // get LCD display status byte
{
int lcd_status;

set_tris_b(0xFF); //DATAIN; // make 8-bit parallel port an input
CD=1; //HI; // bring LCD C/D line high (read status byte)
RD=0; //LO; // bring LCD /RD line low (read active)
CE=0; //LO; // bring LCD /CE line low (chip-enable active)
lcd_status = portb; //inp(pdata); // read LCD status byte
CE=1; //HI; // bring LCD /CE line high, disabling it
RD=1; //HI; // deactivate LCD read mode
set_tris_b(0x00); //DATAOUT; // make 8-bit parallel port an output port

return(lcd_status);
} // sget()

/* ----------------------------------------------------------- */

void dput(int dbyte) // write data byte to LCD module over par. port
// assume PC port in data OUTPUT mode
{
do {} while ((0x03 & sget()) != 0x03); // wait until display ready
CD=0; //LO;
WR=0; //LO; // activate LCD's write mode
portb = dbyte; //outp(pdata, byte); // write value to data port
CE=0; //LO; // pulse enable LOW > 80 ns (hah!)
CE=1; //HI; // return enable HIGH
WR=1; //HI; // restore Write mode to inactive

// using my P5/75 MHz PC with ISA bus, CE stays low for 2 microseconds

} // end dput()

/* ----------------------------------------------------------- */

int dget(void) // get data byte from LCD module
{
int lcd_byte;

do {} while ((0x03 & sget()) != 0x03); // wait until display ready
set_tris_b(0xFF); //DATAIN; // make PC's port an input port
WR=1; //HI; // make sure WRITE mode is inactive
CD=0; //LO; // data mode
RD=0; //LO; // activate READ mode
CE=0; //LO; // enable chip, which outputs data
lcd_byte = portb; //inp(pdata); // read data from LCD
CE=1; //HI; // disable chip
RD=1; //HI; // turn off READ mode
set_tris_b(0x00); //DATAOUT; // make 8-bit parallel port an output port

return(lcd_byte);
} // dget()

/* ----------------------------------------------------------- */

void cput(int dbyte) // write command byte to LCD module
// assumes port is in data OUTPUT mode
{
do {} while ((0x03 & sget()) != 0x03); // wait until display ready

portb = dbyte; //outp(pdata, byte); // present data to LCD on PC's port pins

CD=1; //HI; // control/status mode
RD=1; //HI; // make sure LCD read mode is off
WR=0; //LO; // activate LCD write mode
CE=0; //LO; // pulse ChipEnable LOW, > 80 ns, enables LCD I/O
CE=1; //HI; // disable LCD I/O
WR=1; //HI; // deactivate write mode

} // cput()

/* ----------------------------------------------------------- */

Enjoy :-)


Top
 Profile  
 
 Post subject: A little example to use.
PostPosted: Tue Apr 06, 2010 22:33 
Offline

Joined: Mon Apr 05, 2010 1:08
Posts: 3
Following a little example to use the "adapted rotine"

First you coppy all rotine and save as file like "24064PGB.c".
Now you can use this file like a library.

I make a simple project to print "TEST" on display, I copy all source here.

Souce code:

#include <16F648A>

#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection

#use delay(clock=4000000)

#byte porta=5 //Define a Porta de Saida a como PortA, do registrador 5h
#byte portb=6 //Define a Porta de Saida b como PortB, do registrador 6h

#include <24064PGB>

char texto[20];

void main()
{

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

// TODO: USER CODE!!

porta=0;
portb=0;
set_tris_a(0x00); // todo como saída
set_tris_b(0x00); // todo como entrada
porta=0;
portb=0;

lcd_setup();
lcd_init();
lcd_clear_text();
cput(0x97); // Graphics & Text ON, cursor blinking
lcd_xy(0,0);
texto = "TESTE";


do{


delay_ms(5000);
lcd_print(texto);
lcd_xy(0,0);

}while(true);


}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 59 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group