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 support@ccsinfo.com

RA8835 drivers for 320x240 LCD

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
sliders_alpha



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

RA8835 drivers for 320x240 LCD
PostPosted: Sat Jun 20, 2009 6:51 pm     Reply with quote

hi,

I lost days trying to figure out where CCS's drivers were wrong and I finally gave up. In two hours I coded perfectly (I guess) a working driver for it:

-It only works for 320x240 LCD, parameters such as FX, char width, etc are frozen.
- You can change any pin (DB0-DB7, A0, CS, RST, etc).
- Compatible with CCS graphic.c
- It's for 8080 mode.

Driver :
Code:

#define GLCD_RST PIN_A5
#define GLCD_RD PIN_A1
#define GLCD_WR PIN_A0
#define GLCD_CS PIN_A2
#define GLCD_A0 PIN_A3

#DEFINE GLCD_DB0 PIN_B5
#DEFINE GLCD_DB1 PIN_B4
#DEFINE GLCD_DB2 PIN_B3
#DEFINE GLCD_DB3 PIN_B2
#DEFINE GLCD_DB4 PIN_B1
#DEFINE GLCD_DB5 PIN_B0
#DEFINE GLCD_DB6 PIN_C4
#DEFINE GLCD_DB7 PIN_C3

#define GLCD_WIDTH         320
#define GLCD_HEIGHT        240
#define GLCD_CHAR_WIDTH    8
#define GLCD_CHAR_HEIGHT   8

#define ON                 1
#define OFF                0
#define COMMAND_MODE   output_high(GLCD_A0);
#define DATA_MODE       output_low(GLCD_A0);

#DEFINE RA8835_GRAPHICSTART 0x2580

void GlcdPutData(INT8 data);
int8 TakeData(void);
void GLCD_WriteCommand(int8 commandToWrite);
void GLCD_WriteData(int8 dataToWrite);
int8 GLCD_ReadData(void);
void setCursorAddress(int16 addr);
void GlcdGotoTextXY(int16 x, int16 y);
void GlcdPutC(char c);
void FillText(char cara);
void FillGraphic(int1 parameter);
void glcd_RAinit(void);
int8 GLCD_ReadStatus(void);

void GlcdPutData(int8 data)
   {
   output_bit(GLCD_DB0, bit_test(data,0));     
   output_bit(GLCD_DB1, bit_test(data,1));                   
   output_bit(GLCD_DB2, bit_test(data,2));                   
   output_bit(GLCD_DB3, bit_test(data,3));
   output_bit(GLCD_DB4, bit_test(data,4));
   output_bit(GLCD_DB5, bit_test(data,5));                   
   output_bit(GLCD_DB6, bit_test(data,6));                 
   output_bit(GLCD_DB7, bit_test(data,7));
   }
   

   
int8 TakeData(VOID)
   {
   INT8 data = 0;
   data += input (GLCD_DB0);
   data += input (GLCD_DB1) * 2;
   data += input (GLCD_DB2) * 4;
   data += input (GLCD_DB3) * 8;
   data += input (GLCD_DB4) * 16;
   data += input (GLCD_DB5) * 32;
   data += input (GLCD_DB6) * 64;
   data += input (GLCD_DB7) * 128;
   RETURN data;
   }

void GLCD_WriteCommand(int8 commandToWrite)
{
GlcdPutData(commandToWrite);

COMMAND_MODE

output_low(GLCD_WR);
output_low(GLCD_CS);

delay_cycles(1);

output_high(GLCD_WR);
output_high(GLCD_CS);
}

void GLCD_WriteData(int8 dataToWrite)
{
GlcdPutData(dataToWrite);

DATA_MODE

output_low(GLCD_WR);
output_low(GLCD_CS);

delay_cycles(1);

output_high(GLCD_WR);
output_high(GLCD_CS);
}

int8 GLCD_ReadData(void)
{
int8 tmp;

output_low(GLCD_RD);
output_low(GLCD_CS);
delay_cycles(4);
tmp = TakeData();
output_high(GLCD_RD);
output_high(GLCD_CS);

return tmp;
}

void glcd_RAinit(void)
{
 
   output_high(GLCD_RST);
   output_high(GLCD_CS);
   output_high(GLCD_RD);
   output_high(GLCD_WR);
   
   //system set
   GLCD_WriteCommand(0x40);
   GLCD_WriteData(0x30);
   GLCD_WriteData(0x87);
   GLCD_WriteData(0x07);
   GLCD_WriteData(0x27);
   GLCD_WriteData(0x2F);
   GLCD_WriteData(0xEF);
   GLCD_WriteData(0x28);
   GLCD_WriteData(0x00);
   
   //scroll
   GLCD_WriteCommand(0x44);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0xF0);
   GLCD_WriteData(0x80);
   GLCD_WriteData(0x25);
   GLCD_WriteData(0xF0);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x4B);
   GLCD_WriteData(0x00);
   GLCD_WriteData(0x00);
   //HDOT SCR
   
   GLCD_WriteCommand(0x5A);
   GLCD_WriteData(0x00);
   
   //OVLAY
   GLCD_WriteCommand(0x5B);
   GLCD_WriteData(0x01);
   
   //erase all screen
   FillGraphic(OFF);
   FillText(' ');
   
   //DISP ON
   GLCD_WriteCommand(0x58);
   GLCD_WriteData(0x56);
   
   //CSRFORM
   GLCD_WriteCommand(0x5D);
   GLCD_WriteData(0x04);   
   GLCD_WriteData(0x86);
   
   //DISP ON
   GLCD_WriteCommand(0x59);
   
   //CSDIR
   GLCD_WriteCommand(0x4C);
   
   //CSRW
   setCursorAddress(0x0000);
}


void FillGraphic(int1 parameter)
   {
   long count;
   //set cursor to 2580h
   setCursorAddress(0x2580);
   //put 00h in all graphic space
   count = 9600;
   GLCD_WriteCommand(0x42);
   while(count != 0)
      {
       GLCD_WriteData(0xFF * parameter);
      count--;
      }
   }
   
void FillText(char cara)
   {
   long count;
   //set cursor to 0000h
   setCursorAddress(0x0000);
   //put 00h in all text space
   count = 1200;
   GLCD_WriteCommand(0x42);
   while(count != 0)
      {
       GLCD_WriteData(cara);
      count--;
      }
   }
   
void GlcdPutC(char c)
   {
   GLCD_WriteCommand(0x42);
   GLCD_WriteData(c);
   }
   
//x and y : 1 to max   
void GlcdGotoTextXY(int16 x, int16 y)
   {
   int16 adress = 0;
   adress = (y-1)*40;
   adress = adress+ x-1;
   setCursorAddress(adress);
   }
   
void setCursorAddress(int16 addr)
{
   int8 adress;
   GLCD_WriteCommand(0x46);
   adress = addr & 0xFF;
   GLCD_WriteData(adress);
   adress = addr >> 8;
   GLCD_WriteData(adress);
}

void GLCD_Pixel(int16 x,int16 y, int1 color)
{
int8 tmp = 0;
int16 address = 0;

address = RA8835_GRAPHICSTART + (40 * y) + (x/8);
setCursorAddress(address);

GLCD_WriteCommand(0x43);
tmp = GLCD_ReadData();

if(color == ON)
  tmp |= (1 << (7 - (x % 8)));
else
  tmp &= ~(1 << (7 - (x % 8)));

setCursorAddress(address);
GLCD_WriteCommand(0x42);
GLCD_WriteData(tmp);
}

void GLCD_GraphicGoTo(int16 x,int16 y)
{
setCursorAddress(RA8835_GRAPHICSTART + (y * 40) + x/8);
}

int8 GLCD_ReadStatus(void)
{
int8 tmp;

output_low(GLCD_RD);
output_low(GLCD_CS);
output_low(GLCD_A0);
delay_cycles(1);
tmp = takedata();
output_high(GLCD_RD);
output_high(GLCD_CS);
output_high(GLCD_A0);

return tmp;
}

test prog :
Code:

#include <16F876A.H>
#fuses HS, NOWDT, NOPROTECT
#use delay(clock = 20000000)

#define LARGE_LCD 1
#include <RA8835V2.c>
#include <graphics.c>

void main(void)
   {
   
   glcd_RAinit();
   printf(GlcdPutC,"test lol");
   GlcdGotoTextXY(20,25);
   printf(GlcdPutC,"OMG I'M MOVING");
   glcd_circle(100,100,70,1,1);
   glcd_circle(250,180,30,1,1);
   glcd_rect(200,1,300,80,1,1);
   
   glcd_line(10,239,110,200,1);
   glcd_line(100,239,10,200,1);
   glcd_line(40,220,80,220,1);
   glcd_line(58,230,58,209,1);
   }


Result :

_________________
yup, i know, i don't speak english very well

CCS V4.057
philzn00b



Joined: 09 Apr 2010
Posts: 1

View user's profile Send private message MSN Messenger

PostPosted: Sat Apr 10, 2010 7:14 am     Reply with quote

Hey sliders,

I'm using a PIC16F876 with a graphic LCD (NHD-320240WX-CoTFH-V#I040) that has onboard RA8835.
http://www.newhavendisplay.com/specs/NHD-320240WX-C0TFH-VI040.pdf

I'm using your driver with your test program and I'm getting nothing on my screen except a vertical line or a full screen. I've got another demo program from the company itself which I edited for my PIC and from that one I'm getting the same vertical line. I've checked my wiring multiple times, I've even took it all apart and did it again 2 times already. I'm powering my PIC with 3.3V since my LCD requires that on all data pins. I have no ideas left. Have you experienced something similar in your work at the time? Now all I can think of it is that my LCD or something on its board is burned down. So I have ordered another one that I'll get Monday but do you have any ideas of something else wrong??

Thanks for taking time Smile
sliders_alpha



Joined: 03 Mar 2008
Posts: 55

View user's profile Send private message

PostPosted: Sat Apr 10, 2010 2:44 pm     Reply with quote

Yes, I have experienced exactly the same thing.....with 3 LCD.

It can be a hardware issue, or a timing one (the vertical line means that your LCD isn't initialised).

First: Be sure that your LCD is in 8080 mode. SEL1 (18) should be at 0L.

It will take time but it's the only way to know if it's from you or the LCD, take your oscilloscope, and look at each wire one by one.

Double or triple my delay. I've shortened them by testing how fast my screen could go.

============================================

jte le fais en français au car mon anglais est pas toujours terrible =D

donc, j'ai eu ce problemme avec 3 ecran, la barre verticale veut dire que ton ecran n'est pas initialisé.

normalement, si tu la voi et que tu peux modifier le contraste avec le potar alors l'ecran n'est pas griller (ça va vite, j'en ai griller 2 ça prend moins de 50ms^^)

verifie vien que tu sois en 8080, que SEL1 soit a 0L (attention, des fois il ne faut rien brancher sur cette pin, le niveau est deja imposé par un soudure sur la carte du LCD, c'est mon cas)

la seule chose qui ma permis de resoudre le problemme etait de : regarder chaque fil un par un avec mon oscillo pendant l'init pour voir que j'avais bien ce qui devait arriver dessus.

allonge les delay, double ou triple les. je les ai reduit jusqua la limite max de mon ecran
_________________
yup, i know, i don't speak english very well

CCS V4.057
lucasromeiro



Joined: 27 Mar 2010
Posts: 167

View user's profile Send private message

PostPosted: Thu Jun 03, 2010 1:09 pm     Reply with quote

Hello, I am also looking for how does one use an LCD the same size as yours, but mine is this:
http://cgi.ebay.com/3-5-TFT-LCD-Module-Display-Touch-Panel-PCB-adapter-/200414904304?cmd=ViewItem&pt=AU_CashRegisterAccessories&hash=item2ea9a8bff0

There is something that can help me?
vanyinet



Joined: 03 Jan 2011
Posts: 1

View user's profile Send private message

Re: RA8835 drivers for 320x240 LCD
PostPosted: Mon Jun 06, 2011 2:11 am     Reply with quote

Hi,

I have an 320x240 LCD with a RA8835.
I am desperate because I can't get it work.
I have a bad feeling that the LCD (new) is bad.

My question is if I only apply the power supply (+5V and GND) should I see something on the LCD? I mean applying power supply should turn on weakly the 320x240 pixels as part of an internal initialization? If I do not apply contrast at all should I see this initialization?

I did the following:
- apply power supply => nothing happens LCD
- apply power supply + applying GND (via a 10K potentiometer) to LCD contrast (VREG) => nothing happens LCD

Please help.

Steve
shalts



Joined: 20 Oct 2006
Posts: 11
Location: Ankara

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number

same not working
PostPosted: Thu Aug 18, 2011 5:22 am     Reply with quote

Hello all ,

Like Steve, I am desperate, feeling the same. I couldnt make my 320x240 RA8835 worked out. I tried everyway posted in the forums. I can see nothing on LCD. Pure clear blue:) Yes I checked its 8080 , yes I checked every pin connection. But I have no idea about the timings. I couldnt figure out what exactly mean the "delay cycles" , which, and where ..
_________________
Murat Shalt Unal
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
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