View previous topic :: View next topic |
Author |
Message |
sung
Joined: 10 Jul 2009 Posts: 7
|
Has anyone used Optrex F-51854 graphic LCD? |
Posted: Tue Aug 11, 2009 12:18 pm |
|
|
I'm having a problem in initializing and displaying anything on the LCD. Does anyone have driver source code for the LCD or other helpful things?
I've looked at driver source code for similar modules, but they don't provide me much help..
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 11, 2009 12:20 pm |
|
|
Post a link to the webpage for that module. Post a link to the data sheets
for the module and the controller. |
|
![](templates/subSilver/images/spacer.gif) |
sung
Joined: 10 Jul 2009 Posts: 7
|
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 11, 2009 6:00 pm |
|
|
You will need a complete 8 bit port on the pic - to drive this - as it looks like a pure 8 wide data bus - with a conceptually simple method to address and display BLITS.
Of course what you did not post is the pesky INSTRUCTION set for the part && without THAT - nobody is taking it anywhere. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 11, 2009 6:03 pm |
|
|
The commands for the LCD controller are in his 3rd link. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 11, 2009 7:05 pm |
|
|
serial style is probably best for PIC use
i can't find a useful ref to the controller
so this is a write from scratch job
ball's in your court SUNG
POST the code you wrote that is not working - maybe there is an EZ
clue in that |
|
![](templates/subSilver/images/spacer.gif) |
sung
Joined: 10 Jul 2009 Posts: 7
|
Code that I made up |
Posted: Wed Aug 12, 2009 11:23 am |
|
|
Here's what I wrote.
Please be patient with my code, since I am a beginner in this area.
Thank you.
Code: | //Graphic_LCD_driver.c
//LCD driver for F-51854GNFJ-SLW-ABN Optrex Graphic LCD
//made by Sung Joon Kim on July 25th, 2009
//F-51854 uses S1D15714 LCD controller
//Refer to the data sheet in the initiallization block diagarm of S1D15714
#include <18f4520.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4MHz)
/******************************************************************************/
/* Pin Assignments */
/******************************************************************************/
#define RES pin_e0
#define A0 pin_c0
#define WR pin_c1
#define RD pin_c2
#define LED pin_c3
#define CS1 pin_b0
#define CS2 pin_b1
#define D0 pin_d0
#define D1 pin_d1
#define D2 pin_d2
#define D3 pin_d3
#define D4 pin_d4
#define D5 pin_d5
#define D6 pin_d6
#define D7 pin_d7
/******************************************************************************/
/* Constants */
/******************************************************************************/
//Constants for commands // (command number)
#define DISPLAY_ON 0xaf // (1)
#define DISPLAY_NORMAL 0xa6 // (2)
#define DISPLAY_REVERSE 0xa7
#define LIGHT_NORMAL 0xa4 // (3)
#define LIGHT_ALL 0xa5
#define COM_SCAN_DIR_NORMAL 0xc4 // (4)
#define COM_SCAN_DIR_REVERSE 0xc5
#define DIS_START_LINE_MODE 0x8a // (5)
#define DIS_START_LINE_00 0x00
#define PAGE_ADD_0 0xb0 // (6)
#define DIS_DIR_COLUMN 0x84 // (10)
#define COLUMN_ADD_DIR_NORMAL 0xa0 // (11)
#define COLUMN_ADD_DIR_REVERSE 0xa1
#define REV_LINE_COUNT_4 0x30 // (12)
#define NLINE_INV_OFF 0xe4 // (13)
#define DUTY_SET_COMMAND 0x6d // (14)
#define DUTY_65 0xf0
#define BUILT_IN_OSC_OFF 0xaa // (17)
#define BUILT_IN_OSC_ON 0Xab
#define BUILT_IN_OSC_FREQ_100 0x70 // (18)
#define LCD_POWER_CONTROL 0x25 // (19)
#define LCD_POWER_CONTROL_ALL 0x07
#define LCD_DRIVE_6 0x26 // (20)
#define LCD_BIAS_RATIO_8 0x50 // (21)
#define E_VOL_MODE 0x81 // (22)
#define E_VOL_REG_64 0x40 // 64 in hex
#define TEMP_GRAD_06 0x48 // (25) -0.06 temperature gradient
#define RES_COMMAND 0xe2 // (27)
/******************************************************************************/
/* Function Definition */
/******************************************************************************/
void glcd_control(int control); // send control command
void glcd_write_data(int data);
void glcd_init(void);
/******************************************************************************/
/* Functions */
/******************************************************************************/
/******************************************************************************/
/* void glcd_control(int control) */
/* Purpose: Send control command to the LCD */
/******************************************************************************/
void glcd_control(int control){
//Implement sending control
set_tris_c(0xf0); //Make A0,WR,RD,LED pins as outputs.
output_low(A0); //Select "instruction" command
delay_us(10); //Might need address setup time here
set_tris_b(0xf4); //Make CS1,CS2 pins as outputs.
output_low(CS1); //Send commands to both COGs.
output_low(CS2);
set_tris_d(0x00); //Make Port D output
output_low(WR); //Write the instruction to GLCD
output_high(RD); //Disable Read function
output_d(control); //Load an instruction to Port D.
delay_us(10);
output_high(WR);
output_high(CS1);
output_high(CS2);
}
/******************************************************************************/
/* void glcd_write_data(int data) */
/* Purpose: Send data to the LCD */
/******************************************************************************/
void glcd_write_data(int data){
//(1)Display ON/OFF command
glcd_control(DISPLAY_ON);
/*//(5)Display start line set
glcd_control(DIS_START_LINE_MODE);
glcd_control(DIS_START_LINE_00);
*/
//(10)Display data input direction select
glcd_control(DIS_DIR_COLUMN);
//(6)Page address set
glcd_control(PAGE_ADD_0);
//Actual writing sequence
//setup the condition for writing data.
output_high(A0); //Select "data" command
output_low(CS1); //send commands to both COGs.
output_low(CS2);
//maybe a little delay here
output_high(RD); //Disable Read function
output_low(WR); //Enable Write function
delay_us(5); //Minimum 3us data setup time delay
output_d(data); //Load data to be sent
delay_us(10);
output_high(WR); //Stop writing data
output_high(CS1);
output_high(CS2);
}
/******************************************************************************/
/* void glcd_init() */
/* Purpose: Initiallize the graphic LCD */
/* Occurs after the reset pin has been pushed and released. */
/******************************************************************************/
void glcd_init(){
output_high(pin_b3);
/////////////////////// 1.General Initaillization //////////////////////
set_tris_e(0xfe); //make RES pin an output pin.
//Hard reset
output_low(RES);
//some delay for stable power supply
delay_ms(10);
output_high(RES);
delay_ms(500); //Random delay for playing safe.
/*//(27)soft reset
glcd_control(RES_COMMAND); */
//(11)Column address set direction
glcd_control(COLUMN_ADD_DIR_NORMAL);
//(4)Common output status select
glcd_control(COM_SCAN_DIR_NORMAL);
//(2)Display normal/reverse
glcd_control(DISPLAY_NORMAL);
//(3)Display all lighting ON/OFF
glcd_control(LIGHT_ALL);
//(14)Set the duty
glcd_control(DUTY_SET_COMMAND);
glcd_control(DUTY_65);
//(20)LCD voltage select
glcd_control(LCD_DRIVE_6);
//(22)Electronic volume
glcd_control(E_VOL_MODE);
glcd_control(E_VOL_REG_64);
//(25)Temperature gradient set
glcd_control(TEMP_GRAD_06);
///////////////////// 2.When AC Invert drive is used //////////////////
/* //(12)n-line invert drive register set
glcd_control(REV_LINE_COUNT_4);
//(13)n-line ON/OFF
glcd_control(NLINE_INV_OFF);
*/
/////////////// 3.When the built-in CR oscillator circuit is used /////
//(18)Built-in oscillator circuit frequency select
glcd_control(BUILT_IN_OSC_FREQ_100);
//(17)Built-in oscillator cirucit ON/OFF
glcd_control(BUILT_IN_OSC_ON);
////////// 4.When the Built-in LCD power supply circuit is used //////
//(21)LCD bias change
glcd_control(LCD_BIAS_RATIO_8);
//(19)Power control set
glcd_control(LCD_POWER_CONTROL);
glcd_write_data(LCD_POWER_CONTROL_ALL);
//test if this function has been completed
}
/******************************************************************************/
/* void main(void) */
/* Purpose: Main function of the program (for testing only) */
/******************************************************************************/
void main(void){
glcd_init();
delay_ms(2000);
//Trysing to display random pixels.
glcd_write_data(0x26);
glcd_write_data(0x49);
while(1) {
output_toggle(pin_b2);
delay_ms(500);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Aug 12, 2009 4:49 pm |
|
|
a couple of quick comments
1- you are starting with a very ambitious complex project
2- there are CCS things to be aware of - unless you declared
#FAST_IO you need not do set_tris - compiler will do it for you
yo can get VERY tangled up by confusing that - and THAT could be giving you trouble you dont understand
USE one method or the other - read doc or CCS man pages for more
3-keep it very simple at first
4 check your command def words for accuracy
just try to reliably CLEAR the display and make baby steps at first |
|
![](templates/subSilver/images/spacer.gif) |
|