PDA

View Full Version : WD-C2401P LCD Panel



bogdan
- 23rd October 2010, 01:41
I'm trying to control a WD-C2401P LCD panel (uses the Hitachi HD66717 dot-matrix lcd controller) using a pic16F913 http://ww1.microchip.com/downloads/en/DeviceDoc/41250E.pdf (pic16F913) ... i was following the steps from this page http://www.serialwombat.com/parts/lcd111.htm ..... unfortunately i don't have nothing on the screen


@ __config _INTOSCIO & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _BOD_OFF & _IESO_OFF & _FCMEN_OFF & _CP_OFF & _CPD_OFF & _DEBUG_OFF ;commented the line in the picbasic file

DEFINE OSC 4

OSCCON.0 = 0 'clock source define by FOSC<2,0> = _INTOSCIO (or _LP_OSC)(SCS bit)
OSCCON.6 = 1 'int osc freq 4MHz (IRCF bits)
OSCCON.5 = 1 'int osc freq 4MHz (IRCF bits)
OSCCON.4 = 0 'int osc freq 4MHz (IRCF bits)

CMCON0.2 = 1 'Comparators Off for PORTA.0 to 3 (CM bits)
CMCON0.1 = 1 'Comparators Off for PORTA.0 to 3 (CM bits)
CMCON0.0 = 1 'Comparators Off for PORTA.0 to 3 (CM bits)

ANSEL = 0 'Analog to Digital converter, needs to be disabled prior to use I/O

VRCON.7 = 0 'CVref circuit powered down (VREN bit)

TRISA = %00000000 'sets the PORTA.0 to 7 to outputs
TRISB = %00000000 'sets the PORTB.0 to 7 to outputs
TRISC = %00000000 'sets the PORTC.0 to 7 to outputs

PORTA=%00000000
PORTB=%00000000
PORTC=%00000000

'-------------------------------------------------------------------------------
'VARIABLES

RST Var PORTA.6 'RESET. When this pin is low it resets the LCD. You can either tie this pin to a pin on your microcontroller so you can reset the LCD before initializtion
', or just tie it high. I had a couple of times where I couldn't init the LCD without first resetting it, so I'd recommend putting it under micro control
', or some other powerup controller. The reset low time should be at least 10ms. The time after reset before you start commanding the LCD should also be
'at least 10 ms.

RS VAR PORTC.0 'REGISTER SELECT. This pin determines whether the data you're about to write is a command or a data byte. Commands do interesting stuff to the LCD, like
'set the number of lines or contrast. Data is what actually gets put on the screen, or in the custom character registers. High means Data, Low means
'command

RW VAR PORTA.7 'READ / WRITE. Set this pin high to read from the display. Set this pin low to write to it. If you don't need to update the display super fast you can save an I/O line
'by just tying it to ground. Wait at least a millisecond between each command and data, though, since you can't query the busy status without read
'capability.

E VAR PORTC.4 'ENABLE. This line works to clock in data and commands

DB0 VAR PORTB.1
DB1 VAR PORTB.2
DB2 VAR PORTB.3
DB3 VAR PORTB.4
DB4 VAR PORTB.5
DB5 VAR PORTC.3
DB6 VAR PORTC.2
DB7 VAR PORTC.1

LOW RST
PAUSE 20
HIGH RST
PAUSE 20

LOW RW 'write to lcd

'-------------------------------------------------------------------------------
'Turn on the lcd driver power
LOW E
PAUSE 2
LOW RS 'sending command
PAUSE 2
HIGH E
PAUSE 2

DB0=0
DB1=0
DB2=1
DB3=1
DB4=1 'Turn on the lcd driver power (1C=0001.1000)

PAUSE 2
LOW E
'-------------------------------------------------------------------------------
'Turn on the character display
LOW E
PAUSE 2
LOW RS 'sending command
PAUSE 2
HIGH E
PAUSE 2

DB0=0
DB1=0
DB2=1
DB3=0
DB4=1 'Turn on the character display (14=0001.0100)

PAUSE 2
LOW E
'-------------------------------------------------------------------------------
'Set two display lines
LOW E
PAUSE 2
LOW RS 'sending command
PAUSE 2
HIGH E
PAUSE 2

DB0=0
DB1=0
DB2=0
DB3=1
DB4=0
DB5=1 'Set two display lines (The hd66717 considers 12 characters to be a line. Our 24 character display is actually two 12-character lines right next to each other) (28=0010.1000)

PAUSE 2
LOW E
'-------------------------------------------------------------------------------
'Set to darkest contrast
LOW E
PAUSE 2
LOW RS 'sending command
PAUSE 2
HIGH E
PAUSE 2

DB0=1
DB1=1
DB2=1
DB3=1
DB4=0
DB5=0
DB6=1 'Set to darkest contrast (4F=0100.1111)

PAUSE 2
LOW E
'-------------------------------------------------------------------------------
'Set the data address to the first character
LOW E
PAUSE 2
LOW RS 'sending command
PAUSE 2
HIGH E
PAUSE 2

DB0=0
DB1=0
DB2=0
DB3=0
DB4=0
DB5=1
DB6=1
DB7=1 'Set the data address to the first character (E0=1110.0000)

PAUSE 2
LOW E
'-------------------------------------------------------------------------------
'characters to the lcd
main:

LOW E
PAUSE 2
HIGH RS 'sending characters
PAUSE 2
HIGH E
PAUSE 2

DB0=1
DB1=1
DB2=1
DB3=1
DB4=1
DB5=1
DB6=1

PAUSE 2
LOW E

GOTO MAIN

mackrackit
- 23rd October 2010, 01:52
Look at the LCDOUT command in the manual. With the exception of PIN 3 on your display being a reset it might work.