CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD Display with T6963c and PIC18F4520
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MFK



Joined: 24 Oct 2007
Posts: 12

View user's profile Send private message ICQ Number

LCD Display with T6963c and PIC18F4520
PostPosted: Thu Nov 22, 2007 3:19 pm     Reply with quote

Hi ,

i'm using the Software Protoype Board from CCS and the PIC18F4520.
I got a LCD Display from Displaytech 128240A ( Datasheet http://www.displaytech.com.hk/pdf/graphic/128240a%20series-v11.PDF ). The Display has a T6963c Controller onboard.
I use the PCWH Compile Ver. 3.249.
I'm a beginner with Microcontrollers and although with LCD Displays :-(
I have tried to use the Extended GLCD Driver http://www.ccsinfo.com/forum/viewtopic.php?p=88147&sid=d9d0d4b9b5aa8d853cec821fb14fb251 but it didnt't worked until now.
Is it possible for me to use this Driver ? In the Display Datasheet it's said that ther must be Status Check before using the Display. Do I have to add this to the driver, or do I have to make this Status Check in my own Programm ?
The Driver is for 240 x 64 , how can i adjust the resolution ?
At the beginning of the Driver is written " LCD's FS is tied low (FS = 0 is 8x8 font) " is not a connection or ?
I know thats a lot of question for the beginning.
Thanks a lot.

Greetz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 23, 2007 1:53 pm     Reply with quote

Quote:

In the Display Datasheet it's said that there must be Status Check before
using the Display. Do I have to add this to the driver, or do I have to
make this Status Check in my own Program ?

The driver already does a status check. Here's the code from the driver:
Code:

while (status != 0x03) {  // is LCD busy?
       LCD.r_bar= 0;
       temp = LCD.data;
       LCD.r_bar = 1;
       status = temp & 0x03;
    }


Quote:
The Driver is for 240 x 64 , how can i adjust the resolution ?

The driver has this comment at the beginning:
Quote:

* Works with all resolutions (240x128, 240x64, 128x128),
use glcd_init(240,128);

This implies that you should call the glcd_init() function with parameters
of 240 and 128, no matter what the actual resolution of your LCD.



Quote:

At the beginning of the Driver is written " LCD's FS is tied low
(FS = 0 is 8x8 font) " is not a connection or ?

Yes, the FS signal is on pin 19 of the LCD. Look on page 22 of the LCD
data sheet to see this. You should connect it to Ground.
MFK



Joined: 24 Oct 2007
Posts: 12

View user's profile Send private message ICQ Number

PostPosted: Sun Nov 25, 2007 9:53 am     Reply with quote

Thanks a lot.
Thats really helps me. Unfortunately i cannot test it at the weekend, but i will do on Monday and i hope it works.
MFK



Joined: 24 Oct 2007
Posts: 12

View user's profile Send private message ICQ Number

PostPosted: Mon Nov 26, 2007 7:02 am     Reply with quote

Hi

it nearly seems to working but just nearly.
I tried the example programm

#include <18F452.h>
//#device *=16
//#device adc=10
#use delay(clock=4000000)//,RESTART_WDT)
#use rs232(baud=9600, xmit=PIN_A2,rcv=PIN_A3)
#fuses XT, BROWNOUT, BORV27, PUT, STVREN, NOLVP

#include <T6963C.c>


void main() {
int n;
int8 bt_logo[11] = { //8x11 picture
0b00010000, // XX
0b00011000, // XXXX
0b00010100, // XX XX
0b01010010, // XX XX XX
0b00110100, // XXXX XX
0b00011000, // XXXX
0b00110100, // XXXX XX
0b01010010, // XX XX XX
0b00010100, // XX XX
0b00011000, // XXXX
0b00010000 // XX
};

glcd_init(240,128);
glcd_WriteByte(1, (LCDModeSet|LCDMode_XOR));
glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH));
glcd_gotoxy(3,0,1); // 1 = text area of memory; note that there are only
// 8 rows of text possible
glcd_putc("Hi there.");


glcd_line(30,6,200,50,1);
glcd_line(3,6,20,50,1);
glcd_line(100,40,210,20,1);
glcd_box(14,14,100,60,1);
glcd_box(60,30,100,60,0);
glcd_square(20,12,180,50,1);
glcd_image8(&bt_logo[0],212,40,8,11);
glcd_image8(&bt_logo[0],216,40,8,11);

glcd_line(30,6,200,100,1);

glcd_square(2,32,130,113,1);

glcd_image8(&bt_logo[0],26,110,8,11);
}

but when i run it i just only see some stripes runnig over my display for maybe two seconds and than it stops at the end.
I can see at the PCW Debugger " Ready MCU at 1 MHZ " . Can someone please give me a hint what the problem could be.
Somestimes the programm just get only stucked in one of these while loops.
void glcd_WriteByte(int1 cd, int data)
{
int status = 0, temp = 0;
set_tris_lcd(0xff);
LCD.w_bar = 1;
LCD.r_bar= 1;
LCD.cd = 1;//defaults

while (status != 0x03) { // is LCD busy?
LCD.r_bar= 0;
temp = LCD.data;
LCD.r_bar = 1;
status = temp & 0x03;
}

set_tris_lcd(0x00); // All outputs
LCD.cd = cd; // Command/Data bar
LCD.data = data;
LCD.r_bar = 1; // not read
LCD.w_bar = 0; // write
LCD.w_bar = 1; // release
}


void glcd_WriteByteAuto(int data)
{
int status = 0, temp = 0; // status bits ARE DIFFERENT BITS THAN NORMAL
set_tris_lcd(0xff);
LCD.w_bar = 1;
LCD.r_bar = 1;
LCD.cd = 1; // defaults

while (status != 0x08) { // is LCD busy?
LCD.r_bar = 0;
temp = LCD.data;
LCD.r_bar = 1;
status = temp & 0x08;
}

set_tris_lcd(0x00); // All outputs
LCD.cd = 0; // This is always data, cd=0
LCD.data = data; // Put data on data bus
LCD.w_bar = 0; // write
LCD.w_bar = 1; // release
}

How can i check if my display is really busy ?

The last question , i don't really understand this command.
" #byte LCD = 0xf82 // portC address on 18F452 " ? Im using the PIC 18F4520, shouldnt make a difference , or ?


Thanks a lot.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Nov 26, 2007 9:41 am     Reply with quote

Quote:
The last question , i don't really understand this command.
" #byte LCD = 0xf82 // portC address on 18F452 " ? Im using the PIC 18F4520, shouldnt make a difference , or ?


This overlays the int8 variable know as LCD onto the chip at address 0xF82
And at 0xF82 is port C for the 18F4520.
http://ww1.microchip.com/downloads/en/DeviceDoc/39631d.pdf
page 65 or 63.

So if you read from LCD you are really reading port C
ie: mynewvar=LCD;
and if you write to it you are writing to port C
ie: LCD=0x02;
But the tris must be set for this to work.


btw I would first try simple text in the text area. Save the bit map stuff for when you have read and write working.
MFK



Joined: 24 Oct 2007
Posts: 12

View user's profile Send private message ICQ Number

PostPosted: Tue Nov 27, 2007 9:03 am     Reply with quote

Hi ,

i tried it again today , with no success at the beginning. Than i made the bt sample again and it works fine. Maybe just only a connection was wrong yesterday.
Thanks a lot for the support. I will surely write again :-)

greetz
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

Character problem
PostPosted: Thu Jan 01, 2009 1:49 pm     Reply with quote

Hello,
I am using T6962C graphics driver for my project that uses 24064A LCD from "crystalfontz.com". However I have been encountering this one small problem and I am not sure whats wrong with it.

When ever I print something using glcd_putc(); it prints one extra random character on the screen at the end, like 50% of the time.

For eg. If I try to print

glcd_gotoxy(6,0,1);
glcd_putc(" G-Force");

Then it will print:

G-ForceƄ

I am not sure why some random character are appearing at the end of the word. I would really appreciate if anyone could shed some light.

I am using CCS compiler, PIC18f4685 (40Mhz).

Thanks in advance
Izzy
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 2:53 pm     Reply with quote

Also, one more question,

What do I need to change in the driver code to use 6x8 font?

I have made couple of changes, but the graphics shifted along with the text.

const int8 TextArea =0x0028;
const int8 GraphicsArea = 0x0028;


TextHome = (res_x/6)*res_y; //0x0F00;//0x0780;




Code:
// 240 x 64 in the 8x8 font mode means that 30 characters across by
// 8 rows of characters may be displayed

#define set_tris_lcd(x) set_tris_d(x)
#define LCDColorBlack 0b1
#define LCDColorWhite 0b0

//TRIS DataBus=x,  note:control bus (PORTC) always outputs
unsigned int16 TextHome = 0x0F00;//0x0780;
const int8  TextArea =0x0028; // how many bytes before a new line // 0x28 = 40
const int16 GraphicsHome = 0x0000;
const int8  GraphicsArea = 0x0028; // how many bytes before a new line

const int8 AutoModeWrite = 0xB0;
const int8 AutoModeRead  = 0xB1;
const int8 AutoModeReset = 0xB2;

const int8 LCDModeSet  = 0x80;   // send this OR'd with the following
const int8 LCDMode_OR  = 0b0000;
const int8 LCDMode_XOR = 0b0001;
const int8 LCDMode_AND = 0b0011;
const int8 LCDMode_TA  = 0b0100; // TEXT ATTRIBUTE mode.
const int8 LCDMode_RAM = 0b1000; // 1=CG RAM, 0=internal CG ROM

const int8 LCDSetCursorPtr  = 0x21;  // cursor address
const int8 LCDSetCursorSize = 0xA0;  // 1 line cursor

const int8 LCDDispMode = 0x90;   // send this OR'd with the following
const int8 LCDDisp_BLK = 0b0001;
const int8 LCDDisp_CUR = 0b0010;
const int8 LCDDisp_TXT = 0b0100;
const int8 LCDDisp_GRH = 0b1000;

const int8 LCDBitSet   = 0xF8;
const int8 LCDBitReset = 0xF0;
const int8 LCDBit0 = 0b000;
const int8 LCDBit1 = 0b001;
const int8 LCDBit2 = 0b010;
const int8 LCDBit3 = 0b011;
const int8 LCDBit4 = 0b100;
const int8 LCDBit5 = 0b101;
const int8 LCDBit6 = 0b110;
const int8 LCDBit7 = 0b111;

const int8 LCDSetPtr = 0xE0;



struct lcd_pin_def
{
   BOOLEAN unused1;    // C0
   BOOLEAN unused2;    // C1
   BOOLEAN unused3;  // C2
   BOOLEAN unused4;  // C3
   BOOLEAN w_bar;  // C4 Write bar active low
   BOOLEAN r_bar;  // C5 Read bar active low
   BOOLEAN cd;         // C6 Command/Data BAR   1=command 0=data
   BOOLEAN reset_bar;  // C7 Reset active low
   int  data    :  8;  // PortD=Data bus
};
struct lcd_pin_def  LCD;

  #byte LCD = 0xf82    // portC address on 18F452



////////////////////////////////////////////////////////////////////////////////////////////

#inline
void glcd_init(unsigned int16 res_x, unsigned int16 res_y) {

  int16 counter;

  TextHome = (res_x/6)*res_y; //0x0F00;//0x0780;

  set_tris_c(0x00);  // graphic lcd control lines all output
  set_tris_lcd(0xff);   //TRIS DATA bus,note:control bus always outputs

  LCD.w_bar = 1;      // INITIAL STATES OF CONTROL PINS
  LCD.r_bar = 1;      //
  LCD.cd = 1;         // command

  LCD.reset_bar = 0;  // perform a reset
  delay_us(10);      // delay for a reset
  LCD.reset_bar = 1;  // run

  // Set up the graphics and text areas
  glcd_WriteCmd2(TextHome, 0x40);
  glcd_WriteCmd2(TextArea, 0x41);
  glcd_WriteCmd2(GraphicsHome, 0x42);
  glcd_WriteCmd2(GraphicsArea, 0x43);

  // set address to 0
//  glcd_WriteCmd2(0x0000, 0x24);
  glcd_WriteCmd2(0x0000, 0x24);

  // Clear all RAM of LCD (8k)
  glcd_WriteByte(1, AutoModeWrite);
  for (counter = 0; counter < 0x1fff; counter++)
  {
    glcd_WriteByteAuto(0);    // fill everything with zeros
  }
  glcd_WriteByte(1, AutoModeReset);
}
[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 3:20 pm     Reply with quote

There are several T6963C drivers out there. Post a link to the source
code for it. Also post the name of the person who wrote it. That will
help to identify exactly which one you are using.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 3:31 pm     Reply with quote

I believe this driver was written by "treitmey"

Here is the link

http://www.ccsinfo.com/forum/viewtopic.php?t=19957&highlight=t6963c
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 3:42 pm     Reply with quote

From his driver:
Quote:
void glcd_gotoxy(int x, int y, int1 text) {
// sets memory location to screen location x, y
// location 1,1 is upper left corner; text = 1 (text area), text = 0 (graphics area)

The description says the origin is at (1,1) but you are using 0-based
coordinates in your code below:
Quote:
glcd_gotoxy(6,0,1);

Change the y-coord to 1.
Guest








PostPosted: Thu Jan 01, 2009 4:01 pm     Reply with quote

If I use

glcd_gotoxy(6,1,1);
then the text will appear in second line.

Probably (0,0) was supposed to be the top left hand corner.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 4:04 pm     Reply with quote

Post your compiler version.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 4:11 pm     Reply with quote

Compiler version: 4.013
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 4:22 pm     Reply with quote

That's what I thought. You probably have this problem here:
https://www.ccsinfo.com/forum/viewtopic.php?t=24661&start=74

One possible work-around would be to change the glcd_putc() routine
so it only accepts printable characters. Example:
Changes are shown in bold below:
Quote:
void glcd_putc(char c) {
if(c >= 0x20)
glcd_WriteCmd1(c - 0x20, 0xc0);
}

Try that. See if it fixes the problem.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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