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

Problems with LCD (Batron)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

Problems with LCD (Batron)
PostPosted: Thu Nov 20, 2008 10:28 am     Reply with quote

Hi,
have somebody experience with a Batron LCD? The datasheet from farnell
http://de.farnell.com/batron/bt96040av1-cog-fstf-12-i2c/lcd-module-96x40-i2c/dp/1323370?_requestid=401479.
I just want to see anything on my display, a dot or a line or something else. But I see nothing.
On Pin 1 I measure +3V, and on Pin 6 I measure 10.2 V, as recommended. I set the RES pin on a high level (2.8V) after 100ms. SCL and SDA get signals.
I tried a code from another project which is really long, so I think it is better to ask you for a "simple" code in order to get anything on the display. I use PIC 18F6723 with 20MHz.

Anyway below a part of my code:
Code:
 enum glcd_invtyp {_GLCD_BLACK_ON_WHITE,_GLCD_WHITE_ON_BLACK,_GLCD_ALL_INVERSE};
...

void glcd_putc(char c){
   switch (c) {
     case '\f'   : glcd_clear(); break;
              delay_ms(2);
     case '\n'   : glcd_new_line(); break;
     default    : glcd_send_byte(c,_GLCD_BLACK_ON_WHITE); break;
   }
}
...

while (1) {
   i2c_start();
   glcd_putc("Test ");
   delay_ms(1000);
   i2c_stop();
}


Any idea?
Thanks!
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

PostPosted: Thu Nov 20, 2008 11:52 am     Reply with quote

A part of the code that might be important:
Code:
void glcd_send_byte(BYTE n, glcd_invtyp invtyp ){
   int16 posinrom;
   int i,line,invline;
   byte cmd_mode;
   int1 startchar = 1;
   posinrom = (n - 32);
   posinrom *= 5;
   posinrom += _GLCD_CHARSET_ROM_ADDRESS;
   cmd_mode = (invtyp == _GLCD_ALL_INVERSE) ? _GLCD_CMD_INVERSE : _GLCD_CMD_NORM;
   for(i=0;i<5;i++){
      line=read_eeprom(posinrom+i);
      invline = (invtyp==_GLCD_WHITE_ON_BLACK) ? ~line : line;
      if((line!=0x00) && (n != 0x20) && (n != 0x22)){
         glcd_addx(startchar);
         glcd_write(glcd_x,glcd_y ,invline, cmd_mode);
      } else if (n == 0x20){
         glcd_addx(0);
         glcd_write(glcd_x,glcd_y ,invline, cmd_mode);
         glcd_addx(0);
         glcd_write(glcd_x,glcd_y ,invline, cmd_mode);
         break;
      } else if (n == 0x22){
         glcd_addx(startchar);
         glcd_write(glcd_x,glcd_y ,invline, cmd_mode);
         if(i==4){ break;}
      }
      startchar = 0;
   }
   glcd_addx(0);
   invline = (invtyp==_GLCD_WHITE_ON_BLACK) ? 0xff: 0x00;
   glcd_write(glcd_x,glcd_y ,invline, cmd_mode);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 20, 2008 12:07 pm     Reply with quote

Search for an example driver that you can convert to CCS.
You can search Google for the likely name of a driver file:
Quote:
"bt96040.c"

Then you find code like this:
http://www.hcilab.org/projects/smartits/documentation/bt96040_8c-source.html
http://www.hcilab.org/projects/smartits/code/bt96040.c

Presumably at least some of this code works, and it will give you an
example of how to initialize and use the LCD.
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

PostPosted: Fri Nov 28, 2008 9:04 am     Reply with quote

Hi,
I still have a problem with my LCD.
As mentioned above all signals seem to be ok. But I can't see anything on my display :-( I think it's up to the code.
The driver is the STE2004S.
http://tw.ic-on-line.cn/IOL/datasheet/STE2004S_4145745.pdf
When reading the part about I2C Writing Mode (page 33) first I have to send a byte for the Slave Address, then a Control Byte and after that a Data Byte.
Thus:
Code:

i2c_start();
i2c_write(0x78);    //slave address
i2c_write(0x80);    //controll byte
i2c_write(0x14);    //data byte (for example)
i2c_stop();

But I can't see anything!
Thanks!

P.s.: the guys from hcilab use another driver.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 28, 2008 1:19 pm     Reply with quote

There is driver code for this (in AVR C) about halfway down this thread:
Look for the post by killertoffy where he says "It works!".
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=53045
You can translate this code to CCS. For example, he is doing some
things that are recommended in the data sheet, but which you are
(probably) not doing. Such as, hold the \RES line low to reset the
LCD and then bring it high. Also, the LCD starts up in "power down"
mode. You must write to a register to take it out of that mode. He
does that in his code. Use his code as an example.

This page has the macro for "_BV". Look at the #define statement
about halfway down this page.
http://www.nongnu.org/avr-libc/user-manual/group__avr__sfr.html
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

PostPosted: Wed Feb 11, 2009 8:19 am     Reply with quote

Hi,
after a period of time I try to use this LCD again. But I still have a problem.
Getting a checkerboard is not a problem, but how to write a line or letter is still a problem.

According to the datasheet of the STE2004S I start with the slave address, go further with the DC Control Byte followed by a Data Byte. (see p. 34)
What I want to have is a line in y-Carriage 0011 from D0 to D7 in x-Carriage 4 (see Fig. 18 on p. 19).

So what I do is the following:

Code:
void command (unsigned int8 command) {
i2c_write(0x00);   // 0b10000000 Read i2c address
i2c_write(command);
}

void data (unsigned int8 data)   {
i2c_write(0xC0);//0b11000000 for C0=1 and D/C=1
i2c_write(data);
}

void setFunction (unsigned int8 page, unsigned int8 cmd) {
command(0x20+page);   // 0b00100000 page selector
command(cmd);

}
   
main(){
...
        i2c_start();
   i2c_write(STE2004);
   setFunction(0,0x04);      // 0b00000100 PRS VLCD 2.94V
   setFunction(0,0x17);      // 0b00010111 Charge pump automatic
   setFunction(1,0x14);      // 0b00010100 Bias ratio 3 (equal to 5)
   delay_ms(200); 
   setFunction(0,0x0C);      // 0b00001100 normal LCD mode
   setFunction(0,0x42);          // y-carriage
   setFunction(0,0x85);          // x-carriage
   delay_ms(200);
   data(0xFF);                        // write data to RAM
   delay_ms(1000);
   i2c_stop();
}


It doesn't work!
Any help?
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

PostPosted: Sat Feb 14, 2009 8:01 am     Reply with quote

I solved the problem - easy thing...
The fault was in the void command

Code:
void command (unsigned int8 command) {
i2c_write(0x80);   // 0b10000000 Read i2c address
i2c_write(command);
}

void setFunction (unsigned int8 page, unsigned int8 cmd) {
command(0x20+page);         // 0b00100000 page selector, power down management
command(cmd);
}

void data (unsigned int8 data, int8 col, int8 row)   {
setFunction(0,0x80+col);      // set vertical (X) start point
setFunction(0,0x40+row);      // set horizontal (Y) start point
i2c_write(0xC0);
i2c_write(data);
}
Santford



Joined: 09 Apr 2009
Posts: 2
Location: The Netherlands

View user's profile Send private message

Howto display something?
PostPosted: Thu Apr 09, 2009 9:10 am     Reply with quote

Hi,

I recently bought one of this Batron displays and connected it to a PIC-controller. I've written routines for I2C communication. When I send out bytes to the display, it acknowledges them. When I initlialise the display (set the VLDC, chargepump factor, display normal mode and bias ratio) it turns black. Then I start a memory blank procedure as described in the datasheet and the pixels on the display turn off (and become very light-grey). Now I would like to display something, a line or maybe a character, but can't get it to display anything.

Can someone help me sending the right commands to the display?
mcjames



Joined: 28 Jan 2009
Posts: 1

View user's profile Send private message

PostPosted: Sat Apr 11, 2009 6:21 pm     Reply with quote

Hi, I've been trying to get your code to work (Spom) with my LCD...
After a lot of time being confused, I think I've understood how the LCD works, and yet, I can't get it to do anything at all.

It hasn't even flickered at me.

This is the code I've been trying to use (It's basically the same as above just simplified to only do the checkerboard).

If anyone can see an obvious flaw I'd be greatful... I'm starting to wonder if maybe it's just that my LCD is dead.

Code:

#define LCD_RST PIN_C2
#define LCD_SCL PIN_C3
#define LCD_SDA PIN_C4
#define LCD_ADDRESS_W 0x78
#define LCD_ADDRESS_R 0x79

#use i2c(master, sda=LCD_SDA, scl=LCD_SCL) 

void command (unsigned int8 command) {
i2c_write(0x80);   // 0b10000000 Write next command
i2c_write(command);
}

void setFunction (unsigned int8 page, unsigned int8 cmd) {
command(0x20+page);         // 0b00100000 page selector, power down management
command(cmd);
}

void data (unsigned int8 data, int8 col, int8 row)   {
setFunction(0,0x80+col);      // set vertical (X) start point
setFunction(0,0x40+row);      // set horizontal (Y) start point
i2c_write(0xC0);
i2c_write(data);
}

void init_io(){
SET_TRIS_C(0xA3);//1010 0011 RX(ip).TX(op).NC.SDA(op),SCL(op).NRES(op).NC.NC (RX and TX are irrelevant for this)

output_bit (LCD_RST, 0); //Reset LCD
delay_ms(100);
output_bit (LCD_RST, 1); //Reset LCD
}

void main(){
   init_io();
   i2c_start();
   i2c_write(LCD_ADDRESS_W); //write 0x78
   setFunction(1,0x01); // This should, write, so LCD powers up and sets page to 1. Then checkeboard procedure follows.
   delay_ms(1000);
   i2c_stop();
}
Santford



Joined: 09 Apr 2009
Posts: 2
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Apr 15, 2009 1:19 am     Reply with quote

mcjames wrote:

[...]
Code:

setFunction(1,0x01); // This should, write, so LCD powers up and sets page to 1. Then checkeboard procedure follows.

[...]


That is where you go wrong, the checkerboard instruction allows you to fill the memory with a checkerboard pattern, it doesn't power up your LCD. You have to set the VLDC, biasratio and chargepump to the right values first.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion 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