|
|
View previous topic :: View next topic |
Author |
Message |
leevise
Joined: 05 Aug 2010 Posts: 89
|
Why my OCMJ4X8C-15 LCD doesn't work, and LCD no display |
Posted: Mon Aug 16, 2010 10:38 pm |
|
|
Hello guys, I use the PIC16F877A +12864LCD +CCS. When I download my program, it doesn't work. I don't know what is wrong in my program.
My connections:
Code: |
the LCD pin ----16F877A pin
vss--GND
vdd--5v
vlcd--nc
RS--------------RC2
RW--------------RC7
Enable----------RC6
DB0-------------RD0
. .
. .
. .
DB7-------------RD7
PSB-------------RC1
RST-------------RC5
VOUT------------NC
LED- -----------GND
LED+ -----------5V
|
My program
Code: |
#include <16f877a.h>
#fuses HS,NOWDT,PUT,NOPROTECT
#use delay(CLOCK=20000000)//When use the TMR0 ,not use the delay
#use fast_io(B)
//------------------------------------------------------//
//***************I/O SET MODE**************************//
//-----------------------------------------------------//
#byte RA = 5
#byte RB = 6
#byte RC = 7
#byte RD = 8
#byte RE = 9
//------------------------------------------------------//
//***************LCD SET MODE**************************//
//-----------------------------------------------------//
//#define mode 0
#define uchar unsigned char
#define uint unsigned int
#define DATA RD
#define CONTROL RC
#define input_x input_C
#define set_tris_x set_tris_C
#define enable PIN_C6 // E
#define rs PIN_C2 //
#define psb PIN_C1 //:H
#define /rst PIN_C5 //RESET
#define rw PIN_C7 //
//------------------------------------------------------//
//***************TMR0 MODE**************************//
//-----------------------------------------------------//
void lcd_init(void); //LCD init
void lcd_clear(void); //LCD clear
void lcd_cmd(uchar cmd); //LCD command
void lcd_data(uchar dat); //LCDdisplay data
void chek_busy(void); //busy test
void set_xy(uchar xpos,uchar ypos);
void print(uchar x,uchar y,char* str);
void printstr(uchar xpos,uchar ypos,uchar str[],uchar k);
uchar buf[4]={0xbb,0xb6,0xd3,0xad};
const unsigned char TAB1A[ ]={0xC9,0xEE,0xDB,0xDA,0xC7,0xAC,0xC1,0xFA,0xCA,0xA2,0xB5,0xE7,0xD7,0xD3};
const unsigned char TAB1B[ ]={' ', ' ', 'W', 'W', 'W', '.', 'P', 'I', 'C', '1','6', '.', 'C', 'O', 'M', ' '};
const unsigned char TAB1C[ ]={'T', 'E', 'L' ,'0' ,'7', '5' ,'5','-', '2', '8','1', '8' ,'7','9' ,'7','5'};
const unsigned char TAB1D[ ]={'F', 'A', 'X', '0', '7', '5', '5', '-','2', '8','1', '8', '7', '9', '7', '6'};
const unsigned char Msg[] = "hello";
/********************test busy**********************/
//test
//RS=0,RW=1,E=H,D0-D7
/************************************************/
void chek_busy(void)
{
uchar temp1;//busy
bit_clear(CONTROL,PIN_C2 ); // RS = 0;
bit_set(CONTROL,PIN_C7); // RW = 1;
bit_set(CONTROL,PIN_C6); // E = 1;
do{temp1 = DATA;DATA=0xFF;}
while(temp1&0x80);
bit_set(CONTROL,PIN_C6); // E = 1;
DATA=0xFF;
}
/********************command**********************/
//
//
/************************************************/
void lcd_cmd(uchar cmd)
{
chek_busy();
bit_clear(CONTROL,PIN_C2); //RS = 0;
bit_clear(CONTROL,PIN_C7); //RW = 0;
DATA = cmd;
bit_set(CONTROL,PIN_C6); //E = 1;
delay_us(450);
bit_clear(CONTROL,PIN_C6); //E = 0;
}
/********************write data**********************/
////
/************************************************/
void lcd_data(uchar dat)
{
chek_busy();
delay_ms(100);
bit_set(CONTROL,PIN_C2); //RS = 1;
bit_clear(CONTROL,PIN_C7); //RW = 0;
DATA = dat;
bit_set(CONTROL,PIN_C6); //E = 1;
bit_clear(CONTROL,PIN_C6); //E = 0;
}
/********************init**********************/
//
/************************************************/
void lcd_init(void)
{
set_tris_c(0x00);
set_tris_d(0x00);
bit_set(CONTROL,PIN_C5); //RST=1
bit_set(CONTROL,PIN_C1); //PSB = 1
lcd_cmd(0x30);
lcd_cmd(0x0C);
lcd_cmd(0x01); //0000,0001 clear DDRAM
lcd_cmd(0x02); //0000,0010 DDRAM
lcd_cmd(0x80); //1000,0000 set DDRAM 7bit 000,0000
}
/*******************************************************/
// xpos(1~16),tpos(1~4) //
/*******************************************************/
void set_xy(uchar xpos,uchar ypos)
{
switch(ypos)
{
case 1:
lcd_cmd(0X80+xpos);break; //:0x0080----0x0087
case 2:
lcd_cmd(0X90+xpos);break; //:0x0090----0x0097
case 3:
lcd_cmd(0X88+xpos);break; //:0x0088----0x008F
case 4:
lcd_cmd(0X98+xpos);break; //:0x0098----0x009F
default:break;
}
}
/*******************************************************/
//
/*******************************************************/
void print(uchar x,uchar y,char* str)
{
uchar lcd_temp;
set_xy(x,y);
lcd_temp=*str;
while(lcd_temp != 0x00)
{
lcd_data(lcd_temp);
lcd_temp=*(++str);
}
}
/********************write string******************/
//
//
/**********************************************/
void printstr(uchar xpos,uchar ypos,uchar str[],uchar k)
{
uchar n;
switch (ypos)
{ case 1: xpos |= 0x80;break;
case 2: xpos |= 0x90;break;
case 3: xpos |= 0x88;break;
case 4: xpos |= 0x98;break;
default: break;
}
lcd_cmd(xpos);
for(n=0;n < k;n++)
{
lcd_data(str[n]);
}
}
/*******************************************/
//LCD
/*******************************************/
void lcdinit_str(void)
{
lcd_cmd(0x30);
lcd_cmd(0x08);
lcd_cmd(0x10);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
}
/********************clear************************/
//clear
/************************************************/
void clr_lcd(void)
{
lcd_cmd(0x01);
lcd_cmd(0x34);
lcd_cmd(0x30);
delay_ms(100);
}
/*************************************/
void main ()
{
lcd_init();
lcdinit_str();
printstr(1,1,buf,4);
print(5,1,TAB1B[2]);
print(0,3,Msg[0]);
while(1);
}
|
Last edited by leevise on Fri Aug 20, 2010 2:55 am; edited 1 time in total |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
anybody, give me a demo about 12864LCD |
Posted: Mon Aug 16, 2010 11:59 pm |
|
|
Pls who can give me a demo about 12864LCD. I can't find the error in my program.
Give me some advice! |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
wait for your advice |
Posted: Tue Aug 17, 2010 2:37 am |
|
|
no anyone have demo program? or point out where my error ? |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Tue Aug 17, 2010 3:39 am |
|
|
One problem you have is this:-
Code: |
const unsigned char TAB1B[ ]={' ', ' ', 'W', 'W', 'W', '.', 'P', 'I', 'C', '1','6', '.', 'C', 'O', 'M', ' '};
//In main
print(5,1,TAB1B[2]);
// print routine
void print(uchar x,uchar y,char* str)
{
uchar lcd_temp;
set_xy(x,y);
lcd_temp=*str;
while(lcd_temp != 0x00)
{
lcd_data(lcd_temp);
lcd_temp=*(++str);
}
}
|
you pass print a pointer to index 2 of TAB1B, your TAB1 tables are NOT null terminated. The print routine requires the string to be null terminated. Your routine will continue outputting data passed the end of the TAB1B array until it reaches a null.
The last char in your tables needs to be '\0' or just use
const char TAB1B[] = " WWW.PIC16.COM";
No idea why the 2 spaces are there at the beginning or the space at the end. |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Tue Aug 17, 2010 3:40 am |
|
|
you don't actually give us any idea of what is happening.
Do you get any output ?
Is your code actually running ? How do you know ? |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Tue Aug 17, 2010 7:33 am |
|
|
Does your code actually compile without errors.
I don't think you can declare pointers to constants the way you did. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 17, 2010 11:04 am |
|
|
Quote: | bit_set(CONTROL,PIN_C2); |
This is not correct. Look in the CCS manual and read about a function
before you use it. The manual says:
Quote: |
bit_set( )
Syntax: bit_set(var, bit)
Parameters: var may be a 8, 16 or 32 bit variable (any lvalue)
bit is a number 0- 31 representing a bit number. 0 is the least significant bit.
|
Look in 16F877a.h file to see the #define statement for PIN_C2:
Notice that it's not a bit number (0 to 31).
My advice is, don't write your own lcd driver. Read the data sheet for
your LCD and see what LCD controller it uses. Then find a CCS driver
that is already written for it. (Your links don't go to a LCD data sheet
so I can't help you find it).
CCS graphics lcd drivers:
Quote: |
c:\program files\picc\drivers\hdm64gs12.c
c:\program files\picc\drivers\sed1335.c
|
T6963 driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=19957 |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
my code compile no error |
Posted: Wed Aug 18, 2010 6:38 am |
|
|
guys ,my code compile no error , my LCD no display ,you can copy my program to your CCS compiler in order to debug it,you only get 4 warning but no error. |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Aug 18, 2010 7:33 am |
|
|
i could copy your code and compile it but I can not run it. I dont have
PIC16F877A Development board
or
12864LCD
So I can only help you based on what you post here. If you don't post what I ask then I can not help you.
What are the warnings ?
How do you know it is running ? |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
this LCD instruction |
Posted: Wed Aug 18, 2010 7:44 am |
|
|
1 VSS - GND(0V)
2 VDD - Supply Voltage For Logic (+5V)
3 VO - Supply Voltage For LCD
4 RS(CS) Input
H: Data L: Instruction Code
(chip enable for serial mode)
5 R/W(STD) Input
H: Read L: Write
(serial data for serial mode)
15 PSB Input
H: Parallel Mode
L: Serial Mode
6 E(SCLK) Input
Enable Signal,
(serial clock)
16 NC - NC
17 /RST Input Reset Signal,
18 NC - NC
19 LEDA - (+5V) |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
original code |
Posted: Wed Aug 18, 2010 8:04 am |
|
|
guys ,i post my original code (include 16F877A.H ),when i run it ,the compiler get warning as follow:
original code :
Code: | #include <16f877a.h>
#fuses HS,NOWDT,PUT,NOPROTECT
//#device ADC=10 // AD
#use delay(CLOCK=20000000)//When use the TMR0 ,not use the delay
//#use rs232(BAUD=9600,XMIT=PIN_C6,rcv=PIN_C7)
//#use i2c(MASTER,SDA=PIN_C4,SCL=PIN_C3,ADDRESS=0X9A,FORCE_HW)//I2C
#use fast_io(B)
//------------------------------------------------------//
//************I/O SET MODE****************//
//-----------------------------------------------------//
#byte RA = 5
#byte RB = 6
#byte RC = 7
#byte RD = 8
#byte RE = 9
//------------------------------------------------------//
//**************LCD SET MODE**************//
//-----------------------------------------------------//
//#define mode 0
#define uchar unsigned char
#define uint unsigned int
#define DATA RD
#define CONTROL RC
//#define input_x input_D
#define input_x input_C
//#define output_x output_D
#define set_tris_x set_tris_C
//#define set_tris_x set_tris_D
#define enable PIN_C6 // E 使能端H选通
#define rs PIN_C2 //指令数据选择端
#define psb PIN_C1 //串并口模式选择:H并行L串口
#define /rst PIN_C5 //RESET ,低有效
#define rw PIN_C7 //并行的读写信号
//bit_set(x,y) //相同于#define SETB(x,y) (x|=(1<<y)) //设置将X的第y位置1
//bit_clear(x,y) //相同于#define CLRB(x,y) (x&=(~(1<<y))) //设置将X的第y位清0
//bit_test(x,y) //相同于#define CHKB(x,y) (x&(1<<y)) //检查X的第Y位是1还是0
//#include <lcd_lib2.c>
//------------------------------------------------------//
//*************TMR0 MODE*******************//
//-----------------------------------------------------//
void lcd_init(void); //LCD初始化
void lcd_clear(void); //LCD清屏
void lcd_cmd(uchar cmd); //LCD操作指令
void lcd_data(uchar dat); //LCD显示数据
void chek_busy(void); //busy检测
void set_xy(uchar xpos,uchar ypos);
void print(uchar x,uchar y,char* str);
void printstr(uchar xpos,uchar ypos,uchar str[],uchar k);
uchar buf[4]={0xbb,0xb6,0xd3,0xad}; //welcome
const unsigned char TAB1A[ ]={0xC9,0xEE,0xDB,0xDA,0xC7,0xAC,0xC1,0xFA,0xCA,0xA2,0xB5,0xE7,0xD7,0xD3};
//WWW.PIC16.COM
const unsigned char TAB1B[ ]=" WWW.PIC16.COM";
//{ 'W', 'W', 'W', '.', 'P', 'I', 'C', '1','6', '.', 'C', 'O', 'M', \0 };
//TEL0755-28187975
const unsigned char TAB1C[ ]={'T', 'E', 'L' ,'0' ,'7', '5' ,'5','-', '2', '8','1', '8' ,'7','9' ,'7','5'};
//FAX0755-28187976
const unsigned char TAB1D[ ]={'F', 'A', 'X', '0', '7', '5', '5', '-','2', '8','1', '8', '7', '9', '7', '6'};
const unsigned char Msg[] = "hello";
/********************测忙碌TEST BUSY****************/
//测忙碌子程序
//RS=0,RW=1,E=H,D0-D7=状态字
/************************************************/
void chek_busy(void)
{ uchar temp1;//状态信息(判断是否忙)
bit_clear(CONTROL,PIN_C2 ); // RS = 0;
bit_set(CONTROL,PIN_C7); // RW = 1;
bit_set(CONTROL,PIN_C6); // E = 1;
do{temp1 = DATA;DATA=0xFF;}
while(temp1&0x80);
bit_set(CONTROL,PIN_C6); // E = 1;
DATA=0xFF;
}
/********************写命令write command***********/
//写命令子程序
//
/************************************************/
void lcd_cmd(uchar cmd)/*写命令*/
{
chek_busy();
//delay_ms(100);
bit_clear(CONTROL,PIN_C2); //RS = 0;
bit_clear(CONTROL,PIN_C7); //RW = 0;
DATA = cmd;
bit_set(CONTROL,PIN_C6); //E = 1;
delay_us(450);
bit_clear(CONTROL,PIN_C6); //E = 0;
}
/********************写数据write data***************/
//写数据子程序
//
/************************************************/
void lcd_data(uchar dat)
{
chek_busy();
delay_ms(100);
bit_set(CONTROL,PIN_C2); //RS = 1;
bit_clear(CONTROL,PIN_C7); //RW = 0;
DATA = dat;
bit_set(CONTROL,PIN_C6); //E = 1;
bit_clear(CONTROL,PIN_C6); //E = 0;
}
/********************初始化initializtion******************/
//复位、通讯方式选择 reset , mode
/************************************************/
void lcd_init(void)
{
set_tris_c(0x00);
set_tris_d(0x00);
bit_set(CONTROL,PIN_C5); //复位RST=1
bit_set(CONTROL,PIN_C1); //通讯方式为并口PSB = 1
//send_com(0x34); //34H--扩充指令操作
lcd_cmd(0x30); //功能设置,一次送8位数据,基本指令集
lcd_cmd(0x0C); //0000,1100 整体显示,游标off,游标位置off
lcd_cmd(0x01); //0000,0001 清DDRAM
lcd_cmd(0x02); //0000,0010 DDRAM地址归位
lcd_cmd(0x80); //1000,0000 set DDRAM 7bit address
//000,0000 tocounter AC
}
/*******************************************************/
// 设置显示位置set display position xpos(1~16),tpos(1~4) //
/*******************************************************/
void set_xy(uchar xpos,uchar ypos)
{
switch(ypos)
{
case 1:
lcd_cmd(0X80+xpos);break; //第一行地址为:0x0080----0x0087
case 2:
lcd_cmd(0X90+xpos);break; //第二行地址为:0x0090----0x0097
case 3:
lcd_cmd(0X88+xpos);break; //第三行地址为:0x0088----0x008F
case 4:
lcd_cmd(0X98+xpos);break; //第四行地址为:0x0098----0x009F
default:break;
}
}
/********************************************************/
// 在指定位置显示字符串 display string on specific location
/********************************************************/
void print(uchar x,uchar y,char* str)
{
uchar lcd_temp;
set_xy(x,y);
lcd_temp=*str;
while(lcd_temp != 0x00)
{
lcd_data(lcd_temp);
lcd_temp=*(++str);
}
}
/********************写字符串write string******************/
//写字符串子程序
//xpos1取0~7共八列,ypos1取0~3共四行。
/**********************************************/
void printstr(uchar xpos,uchar ypos,uchar str[],uchar k)
{ uchar n;
switch (ypos)
{ case 1: xpos |= 0x80;break; //第一行
case 2: xpos |= 0x90;break; //第二行
case 3: xpos |= 0x88;break; //第三行
case 4: xpos |= 0x98;break; //第四行
default: break;
}
lcd_cmd(xpos); //此处的Xpos已转换为LCM的显示寄存器实际地址
for(n=0;n < k;n++)
{
lcd_data(str[n]); //显示汉字时注意码值,连续两个码表示一个汉字
}
}
/*******************************************/
//LCD字库初始化函数 LCD character library initializtion
/*******************************************/
void lcdinit_str(void)
{
lcd_cmd(0x30);
//lcd_cmd(0x30);
lcd_cmd(0x08);
lcd_cmd(0x10);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
}
/********************清屏clear display************************/
//清屏
/************************************************/
void clr_lcd(void)
{
lcd_cmd(0x01);
lcd_cmd(0x34);
lcd_cmd(0x30);
delay_ms(100);
}
/**************主函数main function***********************/
void main ()
{
lcd_init(); //set LCD work mode
lcdinit_str();
printstr(1,1,buf,4);
print(5,1,TAB1B[2]); // it will printf "WWW.PIC16.COM",but no display
print(0,3,Msg[0]);
while(1);
}
|
Last edited by leevise on Wed Aug 18, 2010 10:52 pm; edited 1 time in total |
|
|
leevise
Joined: 05 Aug 2010 Posts: 89
|
LCD chip |
Posted: Wed Aug 18, 2010 8:16 am |
|
|
the LCD 12864 chip is ST7920 |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Aug 18, 2010 8:23 am |
|
|
It would have been better without the 16f877a.h header file (unless you have changed it) and if you used CODE tags.
I still can not see the compiler warnings either.
I think there may be a problem with your fuse settings as well. Mabey you need NOLVP but I am not sure of this. |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
hi leevise |
Posted: Wed Aug 18, 2010 11:00 am |
|
|
I will make your display to work, don't be so worried.
Please use 16F877A which I used when I first displayed image on 128x64.
Make sure that the pin connections are like this....
* 1: VSS is connected to GND
* 2: VDD is connected to +5V
* 3: V0 - LCD operating voltage (Constrast adjustment)
* 4: D/I - Data or Instruction is connected to B2
* 5: R/W - Read or Write is connected to B4
* 6: Enable is connected to B5
*7-14: Data Bus 0 to 7 is connected to port d
*15: Chip Select 1 is connected to B0
*16: Chip Select 2 is connected to B1
*17: Reset is connected to C0
*18: Negative voltage is also connected to the 20k Ohm POT
*19: Positive voltage for LED backlight is connected to +5V
*20: Negavtive voltage for LED backlight is connected to GND
and then just copy and paste the programme into your compiler ....
Code: | #include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <HDM64GS12.c>
#include <math.h>
// i splitted the image into four parts because of memory constraints in 16F877A
unsigned char const test_bmp1[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 4, 8,248, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,128,128,128,128,128, 0, 0, 0, 0, 0, 0,
0, 0, 96,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,128,192, 96, 32, 0, 0,128,128, 64, 96, 32, 32, 32,
64, 64,192,128, 0, 0, 0, 0, 0, 0, 0,128, 64, 32, 16, 16,
16, 16, 48,224, 0, 0, 0, 32,192, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned char const test_bmp2[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,240, 12, 6,
2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3,254, 0, 0, 0, 0,
0, 0, 0,254,131, 0, 0, 0, 0, 0,129,255, 56,192, 0, 0,
0, 0, 0, 1, 2, 4, 8, 48,192, 0, 0, 0, 0, 0,192, 32,
16, 8, 4, 3, 0, 0, 0, 6,254, 9, 8, 8, 8, 8, 8, 8,
8, 12, 2, 3, 0, 0, 0, 0, 0, 0, 0,127,130, 4, 4, 4,
4, 4, 6, 3, 0, 0, 0, 0, 1, 2,252, 28, 2, 2, 2, 2,
2, 6, 8, 16,224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 16, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 3, 6,
4, 8, 8, 8, 8, 0, 0, 0, 0, 1, 6, 12, 4, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 4, 4, 8, 8, 8,
8, 24, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 1, 3, 6,
4, 8, 8, 8, 8, 8, 8, 8, 0, 0, 15, 0, 0, 0, 0, 0,
0, 0, 0, 0, 23, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned char const test_bmp3[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,240, 12, 0, 0,
0, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,248,231,160, 32, 32,
16, 12, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,192, 0,128, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,128, 96, 24,132,130,129, 0, 0, 0, 0, 0,
};
unsigned char const test_bmp4[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 1, 1,
2, 2, 4, 8, 16, 16, 16, 32, 64,128, 0, 0, 0, 0, 0, 0,
7, 24, 96,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,128, 96, 30, 1, 0, 15, 48,192,128,192, 32, 16, 8, 4,
4, 4, 4, 12,248,232, 8, 8, 8, 8, 24,224, 0, 0, 0,192,
56, 4, 4, 4,252,128, 0, 0, 0, 2, 2, 2, 2, 4, 8, 8,
248, 16, 28, 34, 65,128, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 6, 8, 16, 48,
48, 0, 0, 7, 24, 32, 64,128,128,128,128,128,128, 64, 64, 48,
12, 2, 1, 0, 0, 0, 0, 0, 0, 1, 31, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 15, 0, 0, 0, 3,
6, 4, 4, 3, 1, 1, 2, 4, 56, 64, 96, 0, 0, 0, 0, 0,
7, 4, 4, 4, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void main() {
int8 i, j, k=0,l=0;
glcd_init(ON);
for(i = 0; i < 8; ++i){
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0b01000000); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0b01000000);
glcd_writeByte(GLCD_LEFT, i | 0b10111000);// Set page address
glcd_writeByte(GLCD_RIGHT, i | 0b10111000);
output_high(GLCD_DI); // Set for data
switch (i) {
case 0: for(j=0,k=0,l=64; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp1[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp1[l]); // Turn pixels on or off
}
break;
case 1: for(j=0,k=128,l=192; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp1[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp1[l]); // Turn pixels on or off
}
break;
case 2: for(j=0,k=0,l=64; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp2[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp2[l]); // Turn pixels on or off
}
break;
case 3: for(j=0,k=128,l=192; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp2[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp2[l]); // Turn pixels on or off
}
break;
case 4: for(j=0,k=0,l=64; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp3[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp3[l]); // Turn pixels on or off
}
break;
case 5: for(j=0,k=128,l=192; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp3[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp3[l]); // Turn pixels on or off
}
break;
case 6: for(j=0,k=0,l=64; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp4[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp4[l]); // Turn pixels on or off
}
break;
case 7: for(j=0,k=128,l=192; j < 64; j++,k++,l++)
{ glcd_writeByte(GLCD_LEFT, test_bmp4[k] ); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, test_bmp4[l]); // Turn pixels on or off
}
break;
}
}
} |
This code will sure display image on your 128x64 display...... enjoy.
I took lot of effort in writing this code.... all CCS guyz you can use copyright by naveenkumar.M ..... |
|
|
|
|
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
|