|
|
View previous topic :: View next topic |
Author |
Message |
Nador
Joined: 10 May 2012 Posts: 5
|
PIC18 and Batron LCD |
Posted: Thu May 10, 2012 3:34 pm |
|
|
Hi guys,
I'm currently facing some trouble dealing with a Batron LCD (BT96040AV1).
It is connected to a PIC18F4520 via I2C.
I'm using C and MPlab IDE v8.
First it took me some days to find out that the LCD now uses another controller (ST7549T) instead of the one provided on the Farnell homepage (STE2004S).
With that information i was able to setup the LCD and turn all segments on (wow i can see something on the screen :D).
But since I'm still a beginner and the data sheet is a little confusing to me, i could need some help on how to write data to the ram / show a dot or a line on the display. I've tried several approaches, but none brought me any results.
The data sheet can be found here for example http://pdf1.alldatasheet.com/datasheet-pdf/view/326159/SITRONIX/ST7549T.html
Here's the working code for setting up the display:
Code: |
#include <main.h>
#define LCD_RST PIN_B3
#define LCD_SCL PIN_C3
#define LCD_SDA PIN_C4
#define LCD_ADDRESS 0x7E
int ack_status;
#use delay(clock=8000000)
#use i2c(MASTER,FAST,SDA=LCD_SDA,SCL=LCD_SCL)
void command (unsigned int8 command) {
i2c_write(0x80); //C0 = 1, A0 = 0, another control byte will follow the data byte
i2c_write(command);
}
void setFunction (unsigned int8 page, unsigned int8 cmd) {
command(0x20+page); //select page
command(cmd);
}
void init_io() {
output_low(LCD_RST);
delay_ms(100);
output_high(LCD_RST);
}
void main() {
init_io();
i2c_start();
ack_status = i2c_write(LCD_ADDRESS);
//set bias system, bias = 9, 1/68 duty
setFunction(1,0x12);
//set D0 = 1
setFunction(1,0x0C);
//set start line
setFunction(1, 0x41);
//set voltage
setFunction(1,0xd8);
//PRS high
setFunction(0,0x05);
//all segments on
setFunction(0,0x09);
delay_ms(500);
//display normal mode
setFunction(0,0x0c);
delay_ms(100);
i2c_stop();
} |
Any help will be appreciated
Thanks in advance.
Jul |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu May 10, 2012 6:57 pm |
|
|
Since it's an I2C device, do you have the correct pullup resistors on the I2C data lines ? |
|
|
Nador
Joined: 10 May 2012 Posts: 5
|
|
Posted: Fri May 11, 2012 1:33 am |
|
|
@PCM programmer
Thanks, this is the thread that helped me getting started and setting up the display, but defining the start points or writing seems to not have any effect... the screens stays blank without showing anything.
@temtronic
i'm using 4.9k pullups, and since the display acknowledges the write of any byte-data it seems fine but thanks for the hint
I'm glad for every response that might help |
|
|
Nador
Joined: 10 May 2012 Posts: 5
|
|
Posted: Sun May 13, 2012 4:01 pm |
|
|
Hi,
Since I'm getting nowhere, I have read the datasheet a few more times but still don't understand how to write data to the display.
I've rewritten my code to avoid any mistakes in the setup process.
If anybody could help me, or post a link where i can find further information on how to drive this display, i would be really grateful!
Thanks in advance.
Jul |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun May 13, 2012 4:12 pm |
|
|
The link PCM referenced you to should have been enough. Post what you
have now so we can help find the error. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Nador
Joined: 10 May 2012 Posts: 5
|
|
Posted: Mon May 14, 2012 5:19 am |
|
|
According to the thread PCM referenced I should use a "data" function to set x and y address and write data.
So this is what my code then looks like (regretfully not showing anything to me).
I tried to understand the graphics (page 20-21) that explain the RAM format but I still don't get the correlation between writing to an address in the RAM specified by a value for x and y and which dot on the display lights up.
Code: |
#include <main.h>
#define LCD_RST PIN_B3
#define LCD_SCL PIN_C3
#define LCD_SDA PIN_C4
#define LCD_ADDRESS 0x7E
int ack_status;
#use delay(clock=8000000)
#use i2c(MASTER,FAST,SDA=LCD_SDA,SCL=LCD_SCL)
void command (unsigned int8 command) {
i2c_write(0x80); //C0 = 1, A0 = 0, another control byte will follow the data byte
i2c_write(command);
}
void setFunction (unsigned int8 page, unsigned int8 cmd) {
command(0x20+page); //select page
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() {
output_low(LCD_RST);
delay_ms(100);
output_high(LCD_RST);
}
void main() {
init_io();
i2c_start();
ack_status = i2c_write(LCD_ADDRESS);
//set bias system, bias = 9, 1/68 duty
setFunction(1,0x12);
//set D0 = 1
setFunction(1,0x0C);
//set start line
setFunction(1, 0x41);
//set voltage
setFunction(1,0xd8);
//PRS high
setFunction(0,0x05);
//all segments on
setFunction(0,0x09);
delay_ms(500);
//display normal mode
setFunction(0,0x0c);
delay_ms(100);
//set start points and write data
data(0xFF,5,2);
i2c_stop();
}
|
I'll keep trying, but it's pretty hard for a newbie |
|
|
Nador
Joined: 10 May 2012 Posts: 5
|
|
Posted: Thu May 24, 2012 7:09 am |
|
|
Hey guys,
Since i'm getting nowhere, can somebody suggest a well-documented graphical display?
Time is passing by really fast, and i need to get my project to work
Thanks again.
Jul |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu May 24, 2012 12:55 pm |
|
|
Hi,
I've had excellent luck with this particular display: http://www.sparkfun.com/products/710 It looks descent, and uses the fairly ubiquitous KS0108 display driver chip. There is a lot of code floating around for this chip, so that should not be a problem. The downside is that this display uses a parallel interface, so it's going to chew up a lot more of your I/O.
John |
|
|
|
|
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
|