PDA

View Full Version : pic16ff with 20*2 lcd



n qwerty
- 17th August 2007, 12:45
having a problem gettin a ew20240ymy working with a pic16f77. just trying to get it to display something but can only get block rectangles on the top line. Have a 100K pot from +5V to gnd for the contrast and this has to be turned to give almost 0v to see the black rectangles. the code below is what im using and cant figure out what im doing wrong.

RS --------- RD0 (pin 19)
E --------- RD1 (pin 20)

D0 to D3 ----GND

D4 to D7 ---- RD4 to RD7 (pin 27 -30)


DEFINE OSC 4

TRISA=%00000000
TRISB=%11111111
TRISC=%00000000
TRISD=%00000000 'set to outputs to drive the LCD

OPTION_REG.7=0 'Enable Pull-Up's on PORTB

ADCON1 = $07


Define LCD_DREG PORTD ' Port for LCD Data
Define LCD_DBIT 4 ' Use upper 4 bits of Port
Define LCD_RSREG PORTD ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 0 ' Port Pin for RS bit
Define LCD_EREG PORTD ' Port for Enable (E) bit
Define LCD_EBIT 1 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)

'Tie R/W pin to oV since the LCDIN will not be used

'start programme here

pause 2000 'initialise LCD

LCDOUT $FE, 1, "Hello"
LCDOUT $FE, $C0, "World"

Any help would be of great use.
cheers