Recently bought Sandhu book on programming the 16F877A and trying to adapt programs to run on the 16F887 which appears pretty similar but am having problems. Nothing but black squares on the lcd. I have entered and run a simple program to switch on each LED on port D in sequence which works OK. The simpler program (below) is supposed to flash the LED on portD bit 0 which it does but also switches on permanently all the other LEDs on portD.
[CLEAR ; clear memory locations
DEFINE OSC 4; Osc speed

LOOP: ; main loop
HIGHPORTD.0 ; turns LED connected to D0 on
PAUSE500 ; delay 0.5 seconds
LOWPORTD.0 ; turns LED connected to D0 off
PAUSE500 ; delay 0.5 seconds
GOTO LOOP; go back to Loop and repeat operation
END; all programs must end with END
]
The program which is supposed to operate the LCD is as follows:
[CLEAR; Define LCD registers and control bits
DEFINE OSC 4; Osc speed]
DEFINE LCD_DREG PORTD; data register]
DEFINE LCD_RSREG PORTE ; select register ]
DEFINE LCD_RSBIT 0 ; select bit] These Defines
DEFINE LCD_EREG PORTE; enable register] are all explained
DEFINE LCD_EBIT 1 ; enable bit] in the PBP
DEFINE LCD_RWREG PORTE ; read/write register] manual.
DEFINE LCD_RWBIT 2 ; read/write bit]
DEFINE LCD_BITS 8 ; width of data path] Can be 4
DEFINE LCD_LINES 2 ; lines in display]
DEFINE LCD_COMMANDUS 2000 ; delay in micro seconds]
DEFINE LCD_DATAUS 50 ; delay in micro seconds]
;
; Set the port directions. We are setting (must set) all of PORTD and all of PORTE as outputs
; even though PORTE has only 3 lines. The other 5 lines will be ignored by the system.
;
TRISD = %00000000; set all PORTD lines to output
TRISE = %00000000; set all PORTE lines to output
; Set the Analog to Digital control register
ADCON1=%00000111; needed for the 16F877A see notes above and below
; this makes all of ports A and E digital.
LOOP:; The main loop of the program
LCDOUT $FE, 1; clear screen, go to position 1
PAUSE 250; pause 0.25 seconds
LCDOUT "HELLO"; print
LCDOUT $FE, $C0; goto second line, first position
LCDOUT "WORLD"; print
PAUSE 250; pause 0.25 seconds to see the display
GOTO LOOP; repeat
END; all programs must end in END
]
This simply produces a row of black squares !
I'm not very good at this and feel sure I am doing something daft... Any comments/help would be appreciated !