Ik heb een probleem met een lcd.
Ik heb twee progjes gemaakt een in JAL en een in MPLAB.
Als ik die van MPLAB in de chip heb dan werkt het niet en als ik die van JAL erin heb dan moet ik de chip een aantal keer spanningsloos maken en dan werkt het wel.
Is mijn chip nu defect of het lcd.

wel een goede initialisatie?

wel een delay bij het opstarten

Ik zal eerst proberen om het met een delay op te lossen. Het rare is dat het wel heeft gewerkt. Maar ik heb toen het een en ander aangepast een toen werkte het niet meer. Toen heb ik het weer zo gemaakt dat alles weer was als voorheen maar het werkte niet meer. Andere progjes zonder LCD wel.

Een extra delay werkt niet.

Het Progje:


	ERRORLEVEL -302
;***************************************************************************************************
; DECLAREREN & CONFIGUREREN
;***************************************************************************************************
	include	P16f877.inc
	list p=16f877
	__config _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC & _LVP_OFF & _BODEN_OFF 
;***************************************************************************************************
; GEHEUGEN STRUCTUUR
;***************************************************************************************************
	ORG 00H
	;MOVLW	D'7'
	;MOVWF	CMCON
	;GOTO BEGIN
;***************************************************************************************************
; POORT DECLAREREN
;***************************************************************************************************
RPO			EQU		05H
COUNTER1	EQU		40H
COUNTER2	EQU		41H	

;	#DEFINE	SCH1		PORTA,1
	#DEFINE	LCD_TRIS	TRISB
	#DEFINE LCD_PORT	PORTB
;***************************************************************************************************
; INPORTEREN BESTANDEN
;***************************************************************************************************
	include	"LCD.INC"
	;include	"Analoog.INC"
	INCLUDE "Text.INC"
	;INCLUDE "RS232.INC"
;***************************************************************************************************
; MACRO`S
;***************************************************************************************************
BANK0	MACRO
		BCF	STATUS,RPO
		ENDM

BANK1	MACRO
		BSF	STATUS,RPO
		ENDM
;***************************************************************************************************
; INSTELLEN UITGANGEN VAN DE POORTEN
;***************************************************************************************************
	BANK1
	;MOVLW	B'00000000'
	;MOVWF	TRISC
	BANK0	
;***************************************************************************************************
; BEGIN PROGRAMMA


BEGIN

	LCD_INIT
	LCD_CLEAR

	LCD_LINE1
	
	LCD_CURSOR_OFF
	TEXT1
	
	LCD_LINE2
	TEXT2	


	
BEGIN2

	GOTO	BEGIN2

	END

De LCD.INC


	LIST

	NOLIST

; LCD control lines
	#define	LCD_RS	4	;0 		; 0 = Command, 1 = Data
	#define LCD_RW	6	;1 		; 0 = Write, 1 = Read
	#define LCD_E	5	;2 		; 1 to send data
	#define LCD_D4	0	;3 		; 4 data lines
	#define LCD_D5	1	;4 
	#define LCD_D6	2	;5 
	#define LCD_D7	3	;6 
	
; Registers we will be using
	#define R_DEL1			0x20	; Delay register
	#define R_DEL2			0x21	; Delay register
	#define R_WDATA_TMP1	0x22
	#define R_WDATA_TMP2	0x23
	#define R_SEND_W_TMP	0x24
	#define	R_WTMP			0x27	; W storage
	#define	R_STMP			0x28	; STATUS storage
	#define	R_STMP1			0x2E	; Send temp register
	#define R_PSEC			0x2F

	CBLOCK	20H
	D1
	D2
	SCROL1
	SCROL2
	ENDC

	;org	00H
	

	;START

LCD_INIT	MACRO	
			CALL	INIT
			LCD_CLEAR
			ENDM

LCD_CHAR	MACRO	CHAR
			MOVLW	CHAR
			CALL	send_w
			ENDM


LCD_CLEAR	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00000001'		; CLEAR LCD
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_CURSOR_HOME	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00000010'		; CURSOR HOME
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_CURSOR_LEFT	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00000100'		; MOVE THE CURSOR TO THE LEFT
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_CURSOR_RIGHT	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00000110'		; MOVE THE CURSOR TO THE RIGHT
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_MOVE_ALL_L	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00011000'		; MOVE TEXT TO LEFT
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_MOVE_ALL_R	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00011100'		; MOVE TEXT TO RIGHT
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_LINE1	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'10000000'		; LINE 1
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_LINE2	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'11000000'		; LINE2
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM


LCD_CURSOR_OFF	MACRO
	bcf		LCD_PORT, LCD_RS	; Command mode
	movlw	b'00001100'		; DISPLAY ON, CURSOR & BLINK OFF
	call	send_w
	bsf		LCD_PORT, LCD_RS	; Data mode
	call	delay_1ms		; Takes a couple of ms
	ENDM

LCD_DELAY	MACRO
		CALL	LCD_DELAY1
		ENDM

LCD_SCROLL_R	MACRO
		CALL	LCD_SCROLL_R1
		ENDM

LCD_SCROLL_L	MACRO
		CALL	LCD_SCROLL_L1
		ENDM


	;org 4
	movwf	R_WTMP		; Save W & STATUS
	swapf	STATUS, W
	movwf	R_STMP
	bcf		STATUS, RP0
	
int_cleanup:
	movlw	b'11111000'	; Clear interrupt bits
	andwf	INTCON, F
	swapf	R_STMP, W	; Restore W & STATUS
	movwf	STATUS
	swapf	R_WTMP, F
	swapf	R_WTMP, W
	retfie

; Init sets all I/O lines as outputs and selects PORTA as
; I/O lines by turning the comparators off.
INIT
	clrf	LCD_PORT
	movlw	0x07
	bsf		STATUS, RP0	; Select bank 1
	movlw	b'00000000'	; Select PORTB as outputs
	movwf	LCD_TRIS
	bcf		STATUS, RP0	; Select bank 0

	; Begin the LCD initialisation
	; Power up timer should give delay, but do it anyway
	movlw	0x14
	call	delay
	
	; Send the command to select 4-bit mode first
	bcf		LCD_PORT, LCD_RS
	bcf		LCD_PORT, LCD_RW
	movlw	0x02			; Still in 8-bit, so appears as 0x20 to LCD
	call	w_to_data
	call	pulse_e

; Should now be in 4-bit mode - send init
	movlw	b'00101000'
	call	send_w
	
	movlw	b'00001110'
	call	send_w
	
	movlw	b'00000110'
	call	send_w
	
; ----------------------

send_w
	movwf	R_SEND_W_TMP
	swapf	R_SEND_W_TMP, F
	movlw	0x0F
	andwf	R_SEND_W_TMP, W
	call	w_to_data
	call	pulse_e
	
	swapf	R_SEND_W_TMP, F
	movlw	0x0F
	andwf	R_SEND_W_TMP, W
	call	w_to_data
	call	pulse_e
	RETURN

w_to_data
	movwf	R_WDATA_TMP1
	movf	LCD_PORT, W
	movwf	R_WDATA_TMP2
	bcf		R_WDATA_TMP2, LCD_D4
	bcf		R_WDATA_TMP2, LCD_D5
	bcf		R_WDATA_TMP2, LCD_D6
	bcf		R_WDATA_TMP2, LCD_D7
	btfsc	R_WDATA_TMP1, 0
		bsf		R_WDATA_TMP2, LCD_D4
	btfsc	R_WDATA_TMP1, 1
		bsf		R_WDATA_TMP2, LCD_D5
	btfsc	R_WDATA_TMP1, 2
		bsf		R_WDATA_TMP2, LCD_D6
	btfsc	R_WDATA_TMP1, 3
		bsf		R_WDATA_TMP2, LCD_D7
	movf	R_WDATA_TMP2, W
	movwf	LCD_PORT
	
	return
	
pulse_e
	bsf		LCD_PORT, LCD_E
	nop
	nop
	nop
	nop
	bcf		LCD_PORT, LCD_E
	call	delay_1ms
	call	delay_1ms
	return

; Calls the delay_1ms routine the number of times specified by
; the W register.
delay
	movwf	R_DEL2
delay_loop
	call	delay_1ms
	decfsz	R_DEL2, F
		goto	delay_loop
	return
	
; When called gives a delay of about 1000 cycles, or 1ms at 4Mhz
; before the next instruction is executed.
delay_1ms
	movlw	d'248'
	movwf	R_DEL1
delay_1ms_loop
	nop
	decfsz	R_DEL1, F
		goto	delay_1ms_loop
	return


LCD_DELAY1	
		MOVLW	D'255'
		MOVWF	D2
LUS1	MOVLW	D'255'
		MOVWF	D1
LUS		DECFSZ	D1,F
		GOTO 	LUS
		DECFSZ	D2,F
		GOTO	LUS1
		RETURN

LCD_SCROLL_R1	
		MOVLW	D'16'
		MOVWF	SCROL2
LOOP1	LCD_MOVE_ALL_R
		LCD_DELAY
		DECFSZ	SCROL2,F
		GOTO	LOOP1		
		RETURN

LCD_SCROLL_L1	
		MOVLW	D'16'
		MOVWF	SCROL1
LOOP2	LCD_MOVE_ALL_L
		LCD_DELAY
		DECFSZ	SCROL1,F
		GOTO	LOOP2		
		RETURN

		LIST

En de TEXT.INC


	LIST
	NOLIST

TEXT1	MACRO
	LCD_CHAR	"P"
	LCD_CHAR	"I"
	LCD_CHAR	"C"
	LCD_CHAR	"."
	LCD_CHAR	"1"
	LCD_CHAR	"6"
	ENDM
	

TEXT2	MACRO	
	LCD_LINE2
	LCD_CHAR 	"F"
	LCD_CHAR	"8"
	LCD_CHAR	"7"
	LCD_CHAR	"7"
	LCD_CHAR	"."
	ENDM
	

	LIST

Ik kan er geen fout in vinden, misschien iemand anders wel of wil heb testen.
Alvast bedankt.

Kan iemand mij hier mee helpen ??.
Ik ben er achter gekomen dat als ik het LCD.INC bestand ga includeren dat het fout gaat. Als de rest wordt toegevoegd is er niets aan de hand. Als ik het progje ga testen in MPLAB dan komt er een output venster naar voren en als alles echt goed is verdwijnt het venster op de achtergrond. Dit is ook het geval als ik het LCD.INC niet gebruik. Maar als ik het wel gebruik blijft het output venster op de voorgrond staan. En toch zit er geen fout in volgens het programma MPLAB.


Clean: Deleting intermediary and output files.
Clean: Deleted file "STANDAARD 16F877 LCD.err".
Clean: Deleted file "C:\ASM\LCD GOED\STANDAARD 16F877 LCD.cod".
Clean: Deleted file "C:\ASM\LCD GOED\STANDAARD 16F877 LCD.hex".
Clean: Deleted file "STANDAARD 16F877 LCD.lst".
Clean: Done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F877 "STANDAARD 16F8777 LCD.asm" /l"STANDAARD 16F877 LCD.lst" /e"STANDAARD 16F877 LCD.err"
Loaded C:\ASM\LCD GOED\STANDAARD 16F877 LCD.COD
BUILD SUCCEEDED: Sun Jul 29 21:56:18 2007

Het probleem is opgelost. Ik had een ; teveel gezet bij goto begin.
Nu werkt het wel weer.