|
|
View previous topic :: View next topic |
Author |
Message |
adrix
Joined: 04 May 2012 Posts: 24
|
128x64 GLCD problem on PIC16F887 |
Posted: Fri May 04, 2012 3:11 pm |
|
|
Hello,
I am using PG12864-F T6963 128x64 graphic lcd, I found all schematics and program codes for pic16f877a. But I am using pic16f887 and when I power up the circuit, the lcd turns on but nothing else happens, maybe I need to change something in the code because I'm using a different mcu? Or maybe there is another problem? I need to make the lcd show something. Thanks in advance for the answers.
Here is the codes:
Code: | /*
***********************************************************************************************
* Use a T6963C 128x64 monochrome LCD for display.
* Fully working prototype based on this software and t6963.c driver
*
* File name : glcdex1.c
* IDE: Microchip's MPLAB v7.01
* Project name: T6963CCS.mcp
* CCS C complier PCM version 3.170
* Programmer : John Leung at www.TechToys.com.hk
* Note : In reference to picant complier web page, & epe magazine for reference
* & treitmey on CCS forum
* Date : Version 0.0 (20 April 2005 - 27 April 2005)
***********************************************************************************************
* DESCRIPTION
*
* This module provides an interface to Toshiba T6963C Graphical LCD of matrix size 128x64 dots
* Schematics:
*
***********************************************************************************************
*/
#include <16F887.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "t6963.h"
#include "t6963.c"
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#include <24256.c>
/*
******************************************************************************************
* PROTOTYPES
******************************************************************************************
*/
void GDispDefIcon32X32(unsigned int8 icon_id);
void GDispIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 icon_id);
void GDispSelIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 mode);
void GDispDefCGPat(void);
void GDispCGPat(unsigned int16 row, unsigned int16 col);
/*
******************************************************************************************
*/
void main()
{
char str[] = "Hey";
GDispInit(); //T6963C display initialization
FontSize = 8; //8 font mode
GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM
GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON
GDispClrTxt(); //Clear the text area
GDispClrGrh(); //Clear the graphics area (dot-by-dot!)
for (;;)
{
GDispDefCGPat(); //read data from eeprom, write to LCD's CG RAM for for DOG picture
GDispCGPat(0, 2); //display the Dog picture from LCD's CG RAM
GDispPixFontAt(85, 20, &str[0], 2, BLACK); //display a 10x14 font for string "Hey" in pixel
Delay_ms(2000); //no need to explain!
GDispClrTxt(); //clear the text area (in this case, clear the dog)
GDispClrGrh(); //clear the graphic area (in this case, clear the string "Hey")
GDispDefIcon32X32(0); //read icon pattern from eeprom, write to LCD's CG RAM, id=0
GDispDefIcon32X32(1); //same as above, id=1
GDispDefIcon32X32(2); //same asa above, id=2
GDispIcon32X32At(2,1,0); //display the icon data stored under CG RAM with id=0
GDispIcon32X32At(2,6,1); //id=1
GDispIcon32X32At(2,11,2); //id=2
GDispSelIcon32X32At(2, 1, ATTR_BLINK_REVERSE); //blink the icon at row,col = 2,1
Delay_ms(2000);
GDispSelIcon32x32At(2,1,ATTR_NORMAL); //bring back to normal mode
GDispSetMode(XOR_MODE|INT_CG_MODE); //some sort of bug here! Try commenting this
//to see what happen with the string "Hey".
GDispClrTxt();
}
}//end of main()
/*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* SET CUSTOM DEFINED ICON OF 32x32 MATRIX FROM EEPROM DATA
*
* Description : This function assigns LCD's CG RAM with a custom icon pattern of 32x32 matrix with
* an id number from I2C EEPROM data
* Arguments : 'icon_id' is the identifier for the icon created.
* Range of 'icon_id' is 0 to 8 for T6963 in 8 Font mode.
* Returns : none
* Notes : icon stored in 24LC256 / 512 eeprom, the first byte from top left, across to down right
*********************************************************************************************************
*/
void GDispDefIcon32X32(unsigned int8 icon_id)
{
unsigned int16 i, col, row;
for(row=0; row<4; row++)
{
for(col=0; col<4; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(32*row + i*4 + col + (unsigned int16)icon_id*128);
}
GDispDefCGChar(col+4*row+icon_id*16,&CGBuffer[0]);
}
}
}
/*
*********************************************************************************************************
* DISPLAY AN ICON OF 32x32 MATRIX AT ROW, COL FROM CG RAM
*
* Description : This function shows a pre-defined 32x32 ICON in CG RAM at (row, col) coordinates
* Arguments : 'icon_id' is the identifier for the pattern created. Range of 'id' is 0...8 in 8 font
* 'row' row = 0...(MAX_ROW_PIXEL/8 - 1), the cell number in 8 bits height
* 'col' col = 0...(COLUMN-1), is the column position in font width (6/8 font)
* Returns : none
* Notes :
*********************************************************************************************************
*/
void GDispIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 icon_id)
{
unsigned int8 id=0;
unsigned int16 row_cnt, col_cnt;
id = id + icon_id*16;
GDispGoto(row, col);
for(row_cnt = row; row_cnt < (row+4); row_cnt++)
{
for(col_cnt = col; col_cnt < (col+4); col_cnt++)
{
GDispCGCharAt(row_cnt, col_cnt, id++);
}
}
}
/*
*********************************************************************************************************
* HIGHLIGHT AN ICON OF 32x32 MATRIX AT ROW, COL
*
* Description : This function highlight an icon at a position row, col.
* Arguments : 'mode' = ATTR_REVERSE, ATTR_INHIBIT, ATTR_BLINK_REVERSE, ATTR_BLINK_INHIBIT,
* ATTR_NORMAL, ATTR_BLINK (all modes defined under t6963.h file)
* 'row' row = 0...(MAX_ROW_PIXEL/8 - 1), the cell number in 8 bits height
* 'col' col = 0...(COLUMN-1), is the column position in font width (6/8 font)
* Returns : none
* Notes :
*********************************************************************************************************
*/
void GDispSelIcon32X32At(unsigned int16 row, unsigned int16 col, unsigned int8 mode)
{
unsigned int16 row_cnt, col_cnt;
for(row_cnt = row; row_cnt < (row+4); row_cnt++)
{
for(col_cnt = col; col_cnt < (col+4); col_cnt++)
{
GDispSetAttrb(row_cnt, col_cnt, mode);
}
}
}
/*
*********************************************************************************************************
* SET CUSTOM DEFINED CG RAM CHARACTERS OF SIZE X*Y MATRIX
*
* Description : This function assigns a custom pattern of X*Y matrix. In this case for Dog_rowx[]
* x = 1 to 8, 9x8 CG RAM characters required
* Arguments : none
* Returns : none
* Notes :
*********************************************************************************************************
*/
void GDispDefCGPat(void)
{
unsigned int16 i, row, col, id;
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+384+col*8);
}
GDispDefCGChar(col,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+456+col*8);
}
GDispDefCGChar(col+9,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+528+col*8);
}
GDispDefCGChar(col+18,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+600+col*8);
}
GDispDefCGChar(col+27,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+672+col*8);
}
GDispDefCGChar(col+36,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+744+col*8);
}
GDispDefCGChar(col+45,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+816+col*8);
}
GDispDefCGChar(col+54,&CGBuffer[0]);
}
for(col=0; col<9; col++)
{
for(i=0;i<8;i++)
{
CGBuffer[i] = read_ext_eeprom(i+888+col*8);
}
GDispDefCGChar(col+63,&CGBuffer[0]);
}
}
/*
*********************************************************************************************************
* DISPLAY CUSTOM DEFINED CG RAM CHARACTERS OF SIZE X*Y MATRIX
*
* Description : This function displays a custom defined pattern of X*Y matrix from CG RAM.
* In this case for Dog_rowx[] data that has been stored by previous project
* x = 1 to 8, 9x8 CG RAM characters required
* Arguments : none
* Returns : none
* Notes :
*********************************************************************************************************
*/
void GDispCGPat(unsigned int16 row, unsigned int16 col)
{
unsigned int16 id=0, row_cnt, col_cnt;
GDispGoto(row, col);
for(row_cnt = row; row_cnt < (row+8); row_cnt++)
{
for(col_cnt = col; col_cnt < (col+9); col_cnt++)
{
GDispCGCharAt(row_cnt, col_cnt, id++);
}
}
} |
Code: | /*
***********************************************************************************************
* Toshiba T6963C Graphical LCD Display Driver
*
* File name : t6963.h
* Programmer : John Leung, TechToys, Hong Kong
* Web presence : www.TechToys.com.hk
* Note : References - picant complier web page, epe magazine Feb 2001
* & Jean J Labrosse's Embedded Systems Building Blocks
* & treitmey's driver on CCS forum
* Language : CCS C complier for PIC mid-range MCU, PCM version 3.170, under MPLAB IDE 7.01
* Hardware : Prototype board PCB ver 2.5(home-grown), EQS Console, MCU 16F877a, 20MHz Xtal
* Date : Version 0.0 (20 April 2005 - 27 April 2005)
* Date : 3 May 2005
* : Routine void GDispPixFontAt(x, y, textptr, size, color) and font5x7.h added
***********************************************************************************************
* DESCRIPTION
*
* This module provides an interface to Toshiba T6963C-0101 Graphical LCD of size 128x64 dots
* A 128-word character generator ROM (code 0101) T6963C-0101 is built in as standard.
* Graphics l.c.d. pinout function
* pin 1 FG frame ground
* pin 2 GND signal ground
* pin 3 +5V Positive supply
* pin 4 CX Negative supply (-3.5V approx)
* pin 5 WR Data write (active low)
* pin 6 RD Data read (active low)
* pin 7 CE Chip enable (active low)
* pin 8 CD CD=1, WR=0: command write
* CD=1, WR=1: command read
* CD=0, WR=0: data write
* CD=0, WR=1: data read
* pin 9 RST Module reset (active low)
* pin 10 - 17 Data bus
* pin 18 FS Font select: FS=0(8x8 font), FS=1(or open circuit, 6x8 font)
* In EQS console ver 2.5 PCB, FS is determined by JP23 jumper. FS=0 when shorted
*
*
***********************************************************************************************
*/
/*
***********************************************************************************************
* PORT DEFINITION
***********************************************************************************************
*/
#byte PORTA = 0x05
#byte TRISA = 0x85
#bit PORTA0 = PORTA.0
#bit PORTA1 = PORTA.1
#bit PORTA2 = PORTA.2
#bit PORTA3 = PORTA.3
#bit PORTA4 = PORTA.4
#bit PORTA5 = PORTA.5
#bit TRISA0 = TRISA.0
#bit TRISA1 = TRISA.1
#bit TRISA2 = TRISA.2
#bit TRISA3 = TRISA.3
#bit TRISA4 = TRISA.4
#bit TRISA5 = TRISA.5
#byte PORTB = 0x06
#byte TRISB = 0x86
#bit PORTB0 = PORTB.0
#bit PORTB1 = PORTB.1
#bit PORTB2 = PORTB.2
#bit PORTB3 = PORTB.3
#bit PORTB4 = PORTB.4
#bit PORTB5 = PORTB.5
#bit PORTB6 = PORTB.6
#bit PORTB7 = PORTB.7
#bit TRISB0 = TRISB.0
#bit TRISB1 = TRISB.1
#bit TRISB2 = TRISB.2
#bit TRISB3 = TRISB.3
#bit TRISB4 = TRISB.4
#bit TRISB5 = TRISB.5
#bit TRISB6 = TRISB.6
#bit TRISB7 = TRISB.7
#byte PORTC = 0x07
#byte TRISC = 0x87
#bit PORTC0 = PORTC.0
#bit PORTC1 = PORTC.1
#bit PORTC2 = PORTC.2
#bit PORTC3 = PORTC.3
#bit PORTC4 = PORTC.4
#bit PORTC5 = PORTC.5
#bit PORTC6 = PORTC.6
#bit PORTC7 = PORTC.7
#bit TRISC0 = TRISC.0
#bit TRISC1 = TRISC.1
#bit TRISC2 = TRISC.2
#bit TRISC3 = TRISC.3
#bit TRISC4 = TRISC.4
#bit TRISC5 = TRISC.5
#bit TRISC6 = TRISC.6
#bit TRISC7 = TRISC.7
#byte PORTD = 0x08
#byte TRISD = 0x88
#bit PORTD0 = PORTD.0
#bit PORTD1 = PORTD.1
#bit PORTD2 = PORTD.2
#bit PORTD3 = PORTD.3
#bit PORTD4 = PORTD.4
#bit PORTD5 = PORTD.5
#bit PORTD6 = PORTD.6
#bit PORTD7 = PORTD.7
#bit TRISD0 = TRISD.0
#bit TRISD1 = TRISD.1
#bit TRISD2 = TRISD.2
#bit TRISD3 = TRISD.3
#bit TRISD4 = TRISD.4
#bit TRISD5 = TRISD.5
#bit TRISD6 = TRISD.6
#bit TRISD7 = TRISD.7
#byte PORTE = 0x09
#byte TRISE = 0x89
#bit PORTE0 = PORTE.0
#bit PORTE1 = PORTE.1
#bit PORTE2 = PORTE.2
#bit TRISE0 = TRISE.0
#bit TRISE1 = TRISE.1
#bit TRISE2 = TRISE.2
//I/O port for data definition
#ifndef T6963_H
#define T6963_H
#define LCD_DATA PORTD // LCD data port
#define LCD_DATA_TRIS TRISD // LCD Data port Tris
#define STA0 PORTD0 // Check command execution capability
#define STA1 PORTD1 // Check data read/write capability
#define STA2 PORTD2 // Check Auto mode data read capability
#define STA3 PORTD3 // Check Auto mode data write capability
#define STA5 PORTD5 // Check controller operation capability
#define STA6 PORTD6 // Error flag. Used for screen peek and screen copy
#define STA7 PORTD7 // Check the blink condition
//Control pin setting
#define LCD_CE PORTE2 // LCD Enable control line pin number
#define LCD_CE_TRIS TRISE2 // LCD Enable control line direction pin #
#define LCD_RD PORTE0 // LCD Read control line pin number
#define LCD_RD_TRIS TRISE0 // LCD Read control line direction pin #
#define LCD_WR PORTE1 // LCD Write control line pin number
#define LCD_WR_TRIS TRISE1 // LCD Write control line irection pin #
#define LCD_CD PORTA4 // LCD Control/data Select line
#define LCD_CD_TRIS TRISA4 // LCD Control/data Select line direction
#define LCD_RST PORTC0 // LCD RST_ line
#define LCD_RST_TRIS TRISC0 // LCD RST_line direction
#endif
/*
***********************************************************************************************
* GLOBAL CONSTANTS
***********************************************************************************************
*/
/*
***********************************************************************************************
* Note : The T6963 controller's RAM address space from $0000 - $FFFF, total 64kbyte RAM.
* It is just the RAM address set, not the actual RAM amount can be set!
* However, everything manufacturer may mount different amount of RAM on its
* module. Example, Powertip's PG12864-F has 4 kbyte RAM only.
* RAM space to handle 128x64 dots in 8 font = 128x64/8 = 1,024 byte.
* Thus, the LCD's actual visible screen area is 1 kbyte.
* For 8-font, 16 COLUMN,
* TEXT_HOME_ADDR starts 0x0000 ending 0x01FF -> 512 bytes (for text use)?
* GRH_HOME_ADDR starts 0x0200 ending 0x05FF -> 1,024 bytes ?
* CG_HOME_ADDR starts 0x1400 ending 0x147F -> 128 bytes (custom characters) ?
***********************************************************************************************
*/
#define TEXT_HOME_ADDR 0x0000
#define GRH_HOME_ADDR 0x0200
#define CG_HOME_ADDR 0x1400
#define COLUMN 16 //Set column number to be e.g. 32 for 8x8 fonts, 2 pages
#define MAX_ROW_PIXEL 64 //MAX_ROW_PIXEL the physical matrix length (y direction)
#define MAX_COL_PIXEL 128 //MAX_COL_PIXEL the physical matrix width (x direction)
#define ENABLE 1
#define DISABLE 0
#define BLACK 1
#define WHITE 0
/*
***********************************************************************************************
* DISPLAY MODE
***********************************************************************************************
*/
#define DISPLAY_OFF 0x90 //0b10010000, display off
#define CURSOR_ON_BLINK_OFF 0x92 //0b1001xx10, cursor on without blinking
#define CURSOR_BLINK_ON 0x93 //0b1001xx11, cursor on with blinking
#define TEXT_ON 0x94 //0b100101xx, text on, graphics off
#define GRAPHIC_ON 0x98 //0b100110xx, text off, graphics on
#define TEXT_GRH_ON 0x9C //0b100111xx, text on, graphics on
/*
***********************************************************************************************
* MODE
***********************************************************************************************
* Example: OR_MODE|EXT_CG_MODE -> OR mode, external CG ram mode
* AND_MODE -> AND mode, internal CG ROM mode
***********************************************************************************************
*/
/*
***********************************************************************************************
* In internal CG ROM MODE (INT_CG_MODE), character codes 00h - 7Fh represent the
* pre-defined "internal" CG ROM characters, and codes 80h - FFh represent the
* users' own "external" characters. In external CG ROM MODE (EXT_CG_MODE),
* all 256 codes from 00h - FFh can be used to represent the users' own characters.
***********************************************************************************************
*/
#define INT_CG_MODE 0x80 //0b10000xxx, Internal CG ROM mode
#define EXT_CG_MODE 0x88 //0b10001xxx, External CG RAM mode
#define OR_MODE 0x80 //0b1000x000, OR mode, internal CG ROM mODE
#define XOR_MODE 0x81 //0b1000x001, XOR mode, internal CG ROM mode
#define AND_MODE 0x83 //0b1000x011, AND mode, internal CG ROM mode
#define TEXT_ATTR_MODE 0x84 //0b1000x100, text attribute mode, internal CG ROM mode
/*
***********************************************************************************************
* CURSOR MODE
***********************************************************************************************
*/
#define LINE_8_CURSOR 0xA7 //8-line cursor mode
#define LINE_7_CURSOR 0xA6 //7-line cursor mode
#define LINE_6_CURSOR 0xA5 //6-line cursor mode
#define LINE_5_CURSOR 0xA4 //5-line cursor mode
#define LINE_4_CURSOR 0xA3 //4-line cursor mode
#define LINE_3_CURSOR 0xA2 //3-Line cursor mode
#define LINE_2_CURSOR 0xA1 //2-Line cursor mode
#define LINE_1_CURSOR 0xA0 //1-Line cursor mode
/*
***********************************************************************************************
* TEXT ATTRIBUTE MODE
***********************************************************************************************
*/
#define ATTR_NORMAL 0x00 //Normal Display
#define ATTR_REVERSE 0x05 //Reverse Display
#define ATTR_INHIBIT 0x03 //Inhibit Display
#define ATTR_BLINK 0x08 //Blinking of Normal Display
#define ATTR_BLINK_REVERSE 0x0D //Blinking of Reverse Display
#define ATTR_BLINK_INHIBIT 0x0B //Blinking of Inhibit Display
/*
***********************************************************************************************
* GLOBAL VARIABLES
***********************************************************************************************
*/
unsigned int8 DisplayMode; /* Keeps state of the display mode (DISPLAY MODE) */
unsigned int8 Mode; /* Keeps state of the MODE */
unsigned int8 FontSize; /* 6 font or 8 font */
unsigned char CGBuffer[8]; /* Buffer for custom pattern */
/*
***********************************************************************************************
* FUNCTION PROTOTYPES
***********************************************************************************************
*/
void GDispInit(void);
void GDispSetMode(unsigned int8 mode);
void GDispClrTxt(void);
void GDispClrGrh(void);
void GDispGoto(unsigned int16 row, unsigned int16 col);
void GDispChar(unsigned char c);
void GDispCharAt(unsigned int16 row, unsigned int16 col, unsigned char c);
void GDispSetCursor(unsigned int8 mode, unsigned int16 row, unsigned int16 col, unsigned int8 type);
void GDispSetPixel(unsigned int16 X, unsigned int16 Y, unsigned int8 color);
void GDispSetAttrb(unsigned int16 row, unsigned int16 col, unsigned int8 mode);
void GDispDefCGChar(unsigned int8 id, unsigned char *pat);
void GDispCGChar(unsigned int8 id);
void GDispCGCharAt(unsigned int16 row, unsigned int16 col, unsigned int8 id);
void GDispBlkIcon32X32At(unsigned int16 row, unsigned int16 col);
void GDispPixFontAt(unsigned int16 X, unsigned int16 Y, unsigned char* textptr, unsigned char size, int1 color);
/*
***********************************************************************************************
* FUNCTION PROTOTYPES
* HARDWARE SPECIFIC
***********************************************************************************************
*/
#define GDispChipEn LCD_CE = 0 /* Low level Chip Enable macro */
#define GDispChipDi LCD_CE = 1 /* Low level Chip Disable macro */
#define GDispCmdWr LCD_DATA_TRIS = 0x00; \
LCD_RD = 1; LCD_CD = 1; \
LCD_WR = 0 /* Low level command write macro */
#define GDispCmdRd LCD_DATA_TRIS = 0xFF; \
LCD_RD = 0; LCD_CD = 1; \
LCD_WR = 1 /* Low level command read macro */
#define GDispDatWr LCD_DATA_TRIS = 0x00; \
LCD_RD = 1; LCD_CD = 0; \
LCD_WR = 0 /* Low level data write macro */
#define GDispDatRd LCD_CD = 0; LCD_WR = 1 /* Low level data read macro */
void GDispInitPort(void);
void GDispBusyChk(void);
void GDispAutoWrChk(void);
void GDispDataWr(unsigned char data);
void GDispAutoDataWr(unsigned char data);
void GDispCmdSend(unsigned char cmd); |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 04, 2012 6:38 pm |
|
|
1. Is this a hardware project or a Proteus project ?
2. If it's hardware, have you ever made the 16F887 do anything, such
as blink an LED once per second ? In other words, does your
board, your ICD programmer, and compiler IDE setup work OK ?
3. He reads and attempt to display a bitmap from a 24LC256 eeprom chip.
Do you have this eeprom chip on your board ? Does it have the
"dog" bitmap in it ? If not, then I suggest that you comment out all
the lines in main() that talk to the eeprom, or that use the data from it.
Just do a test of writing text only. |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Sat May 05, 2012 3:50 am |
|
|
Thanks for the answer.
1. It is a hardware project.
2. I connected a led and it blinks correctly, so I guess everything with schematics and compilers is ok.
3. I have that chip connected and I imported a hex file:
Code: | /*
***********************************************************************************************
* CONTROL CONSOLE EXERCISE
* Use a T6963C 128x64 monochrome LCD for display.
*
*
* File name : eeprom.c
* IDE: Microchip's MPLAB v7.01
* Project name: eepromdat.mcp
* CCS C complier PCM version 3.170
* Programmer : John Leung, TechToys, Hong Kong
* Web presence : www.TechToys.com.hk
* Date : Version 0.0, 5th Jan 2006
***********************************************************************************************
* DESCRIPTION
*
* This program stores 3 icons(32x32) and a picture to eeprom(Microchip's 24LC256) for later
* use with another project (T6963CCS.mcp).
* Use shareware FastLCD designer by Bojan I. MICRODESIGN, version 1.2.0 to convert
* bmp picture to text file (Dog.h and icons.h).
***********************************************************************************************
*/
#include <16F887.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "Dog.h"
#include "icons.h"
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#include <24256.c>
main()
{
unsigned int16 i = 0;
init_ext_eeprom();
for(i=0; i<128; i++)
write_ext_eeprom(i, cygwin_icon[i]); //byte 0-127
for(i=0; i<128; i++)
write_ext_eeprom(i+128, flash_icon[i]); //byte 128-255
for(i=0; i<128; i++)
write_ext_eeprom(i+256, outlook_icon[i]); //byte 256-383
for(i=0; i<72; i++) write_ext_eeprom(i+384, Dog_row1[i]); //offset = 384, byte 0-71
for(i=0; i<72; i++) write_ext_eeprom(i+456, Dog_row2[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+528, Dog_row3[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+600, Dog_row4[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+672, Dog_row5[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+744, Dog_row6[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+816, Dog_row7[i]);
for(i=0; i<72; i++) write_ext_eeprom(i+888, Dog_row8[i]);
for(;;){
;
}
} |
I tried to show only text, but I am new with this ccs compiler, so It didn't show anything. Maybe you have code that I could use to show only text to the lcd.
And btw I connect glcd's contrast pin to the ground, I hope this doesn't make any difference? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat May 05, 2012 6:08 am |
|
|
Yes it makes a difference. What does the datasheet say? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sun May 06, 2012 6:01 am |
|
|
hi,
in the absence of any other information, I would connect the ends of a 10K pot to +5v an GND, and connect the wiper to the GLCD contrast pin. Then adjust the pot until something appears on the GLCD.
John |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun May 06, 2012 6:02 am |
|
|
OK, so the datasheet isn't worth much.
Here is some info from a person who has it working and their connections:
Quote: | 1 FG --- GND
2 Vss --- GND
3 Vdd --- +5V
4 Vo --- -Ve
5 WR --- RB5
6 RD --- RB6
7 CE --- GND
8 CD --- RB4
9 RST --- RB7
10 DB0 --- RD0
11 DB1 --- RD1
.
.
17 DB7 --- RD7
18 FS --- GND
FS can be either to GND or Vcc depending what font size you want.
Vo has to be an external minus voltage controlled by a pot for contrast. |
Note they say Vo is a minus voltage _________________ Google and Forum Search are some of your best tools!!!! |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Mon May 07, 2012 6:43 am |
|
|
Thanks guys I supplied negative voltage to V0 and the lcd works. Just there is a problem that the printed text is not smooth, there are some empty parts in the text, maybe you know how to fix it? Here is a picture:
And here is the program code that I'm using: Code: | #include <16F887.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "t6963.h"
#include "t6963.c"
void main()
{
char str[] = "Hello";
GDispInit(); //T6963C display initialization
FontSize = 8; //8 font mode
GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM
GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON
GDispClrTxt(); //Clear the text area
GDispClrGrh(); //Clear the graphics area (dot-by-dot!)
for (;;)
{
GDispPixFontAt(20, 20, &str[0], 2, black); //display a 10x14 font for string "Hey" in pixel
}
}//end of main() |
|
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Wed May 09, 2012 11:15 pm |
|
|
Ok I got everything working. The problem was that I was using pic16f887 instead of pic16f877a, so I changed ra4, re0, re1, re2 pins to portbB pins. |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Thu May 10, 2012 1:10 pm |
|
|
Here is another problem:
I want to display a variable graphic lcd, but nothing is happening. Here is the code that I'm trying to use:
Code: |
#include <16F887.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "t6963.h"
#include "t6963.c"
char str[] = "1234567890";
char str1[] = "Armantas";
char i[];
void lul ()
{
i++;
return;
}
void main()
{
setup_adc(ADC_OFF);
setup_oscillator(OSC_4MHZ);
GDispInit(); //T6963C display initialization
FontSize = 8; //8 font mode
GDispSetMode(XOR_MODE|INT_CG_MODE); //Exclusive OR mode, internal CG character RAM
GDispSetMode(TEXT_GRH_ON); //Text ON, Graphics ON
GDispClrTxt(); //Clear the text area
GDispClrGrh(); //Clear the graphics area (dot-by-dot!)
// GDispPixFontAt(1, 1, &str[0], 1, BLACK); //display a 10x14 font for string "Hey" in pixel
// GDispPixFontAt(1, 10, &str1[0], 1, BLACK); //display a 10x14 font for string "Hey" in pixel
for (;;)
{
output_high(PIN_A0);
delay_ms(100);
output_low(PIN_A0);
delay_ms(100);
GDispPixFontAt(1, 10, &i[0], 1, BLACK); //display a 10x14 font for string "Hey" in pixel
lul() ;
}
}//end of main()
|
And here is a photo of what the lcd is showing:
So please help me find the problem. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 10, 2012 3:46 pm |
|
|
What does the GDispPixFontAt() expect for it's 3rd parameter ?
It expects a pointer to a string array of ASCII characters.
What are you giving it ? You're giving it a pointer to an empty array.
The array doesn't have any storage (ie, bytes) allocated to it in the
variable declaration statement. It doesn't have an ASCII string in it,
so it won't work.
Here is what you need to do:
1. Declare an array. Make it sufficiently large enough to hold any
reasonable string that you might put in it. This must include storage
space for the terminating zero byte that marks the end of every string.
2. Declare the variable that you want to display. Initialize it to some
value.
3. Use sprintf() to convert the variable into an ascii string. Give sprintf()
the variable and a pointer to the array. It works like printf(), except it
sends the output to your array, instead of sending it out the serial port.
4. Finally, give the address of the array to your GLCD pixel display
function. Since the array now contains an ASCII string, you should see
it displayed on your GLCD. However, this method has no support for
control characters. You would have to create a glcd_putc() function to
provide support for CR, LF, Backspace characters, etc. |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Fri May 11, 2012 5:02 am |
|
|
Thank you very much, everything is working. I have one more question: How can I clear only the changing variable, because if I use GDispClrGrh(); it clears all of my text? I tried to make like this:
Code: | GDispPixFontAt(80, 1, c, 1, BLACK);
delay_ms(50);
GDispPixFontAt(80, 1, c, 1, white); |
But maybe there is a way, that the variable would change more smoothly.
I hope you understand what I mean. |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Sat May 12, 2012 10:31 am |
|
|
Maybe I didn't explained the problem quite good, so I took some photos.
Here's what's shown when I turn on the project:
And here's what happens when I increase the temperature:
How can I make that the numbers would smoothly change? |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sat May 12, 2012 1:55 pm |
|
|
Hi,
Those are extremely poor photos, so you aren't doing us any favors! Is the problem that the old data remains when the new data is displayed, showing both old and new superimposed?
John |
|
|
adrix
Joined: 04 May 2012 Posts: 24
|
|
Posted: Sat May 12, 2012 2:09 pm |
|
|
ezflyr wrote: | Hi,
Those are extremely poor photos, so you aren't doing us any favors! Is the problem that the old data remains when the new data is displayed, showing both old and new superimposed?
John |
Sorry for the photos. Yeah that's exactly the problem. You know how to fix it? |
|
|
|
|
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 You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|