LCDInfo.com
http://forum.lcdinfo.com/

wierd problem with lcd
http://forum.lcdinfo.com/viewtopic.php?f=9&t=801
Page 1 of 1

Author:  jijita [ Mon Aug 30, 2004 8:36 ]
Post subject:  wierd problem with lcd

i'm using a wg12864b lcd ks0108
i figured out how to write to it but there's a problem whenever i write something to the controller CS2 it will write automatically on both controllers the thing that was meant to be on controller CS2 only then in the same program if i choose to write on CS1 i can't.
and if in another code i choose the CS1 controller and write something on it it is written only onthat controller ;but if in the same code i choose after this CS2 to write on i can't write anything
please can anyone tell me what may be the problem i'm really confused

Author:  jijita [ Mon Aug 30, 2004 8:39 ]
Post subject: 

here is the code for the right controller if i try to add something to write on the left controller i can't:
list p=16f877
#include <p16f877.inc>
LCD_DATA EQU PORTC ; LCD data lines interface
LCD_DATA_TRIS EQU TRISC
LCD_CTRL EQU PORTA ; LCD control lines interface

LCD_TEMP EQU 0x020 ; LCD subroutines internal use
R1 EQU 0x21
R2 EQU 0x22
DELAY EQU 0x023 ; Used in DELAYxxx routines
X_DELAY EQU 0x024 ; Used in X_DELAYxxx routines
; PORTA control bits
LCD_E EQU 2 ; LCD Enable control line
LCD_RW EQU 1 ; LCD Read/Write control line
LCD_RS EQU 0 ; LCD Register-Select control line
CS1 EQU 3
CS2 EQU 4
Rst EQU 5
ORG 0X00
GOTO main
main BCF STATUS,RP1 ;turns to Bank 1
BSF STATUS,RP0
MOVLW 0x06 ; Configure all pins
MOVWF ADCON1 ; as digital inputs BSF STATUS,RP0
MOVLW B'00000111'
OPTION

CLRF TRISA
MOVLW H'00'
MOVWF TRISC
BCF STATUS,RP0
CLRF PORTA
CLRF PORTC
BSF LCD_CTRL, LCD_RS ; Set LCD in command
BSF PORTA,5
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CALL DELAI
CALL DELAI
BCF PORTA,5
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CALL DELAI
BSF PORTA,5
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI

NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MOVLW H'07'
CALL WRITE_COMMAND1

MOVLW H'40' ;Set Y Column Address >From 0
CALL WRITE_COMMAND1


MOVLW H'B8' ;Set Page From 0
CALL WRITE_COMMAND1
MOVLW H'C0' ;Set Display Start Line
CALL WRITE_COMMAND1

MOVLW H'3F' ;Set Display ON
CALL WRITE_COMMAND1
SHOWC: CLRF R1
CLRF R2

SCLOOP1:
MOVLW H'B8' ;Set Page Address FROM 00H
ADDWF R1,W ;Command B8H~BFH
CALL WRITE_COMMAND1
; CALL WRITE_COMMAND2
MOVLW 0x40 ;Set Column Address FROM 40H
CALL WRITE_COMMAND1
; CALL WRITE_COMMAND2
SCLOOP2 CALL table
CALL WRITE_DATA1
INCF R2,1
MOVLW D'15'
SUBWF R2,W
BTFSC STATUS,Z
GOTO clea
GOTO SCLOOP2
clea CLRF R2
clearing INCF R2,1
MOVLW H'FF'
CALL WRITE_DATA1
MOVLW D'45'
SUBWF R2,W
BTFSC STATUS,Z
GOTO finale
GOTO clearing
table MOVF R2,W
ADDWF PCL,1
RETLW H'8C'
RETLW H'92'
RETLW H'92'
RETLW H'62'
RETLW H'80'
RETLW H'FE'
RETLW H'92'
RETLW H'92'
RETLW H'92'
RETLW H'80'
RETLW H'8C'
RETLW H'92'
RETLW H'92'
RETLW H'62'
RETLW H'00'
WRITE_COMMAND1 MOVWF LCD_TEMP ; Command to send is in W ;Write Command To CS1
BCF LCD_CTRL,CS2
BSF LCD_CTRL,CS1
BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BCF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
NOP
NOP
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
WRITE_DATA1
MOVWF LCD_TEMP ; Command to send is in W ;Write Command To CS1
BCF LCD_CTRL,CS2
BSF LCD_CTRL,CS1
BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BSF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
WRITE_COMMAND2
MOVWF LCD_TEMP ; Command to send is in W
BCF LCD_CTRL,CS1 ;Write Command To CS1
BSF LCD_CTRL,CS2

BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BCF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
DELAI MOVLW D'255'
MOVWF DELAY
REPEAT DECFSZ DELAY,1
GOTO REPEAT
RETURN
;LCDINIT
; Busy-flag is not yet valid
; CLRF LCD_CTRL ; ALL PORT output should output Low.
; power-up delay
; MOVLW 0x050
; CALL X_DELAY500

; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x009
; CALL X_DELAY500

; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;CALL X_DELAY500
; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x008 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x001 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x007 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD

finale NOP
END

Author:  Henri [ Mon Aug 30, 2004 15:44 ]
Post subject:  Re: wierd problem with lcd

jijita wrote:
whenever i write something to the controller CS2 it will write automatically on both controllers the thing that was meant to be on controller CS2 only

This would happen if you have the both CS pins selected at the same time.

Quote:
then in the same program if i choose to write on CS1 i can't.
and if in another code i choose the CS1 controller and write something on it it is written only onthat controller ;but if in the same code i choose after this CS2 to write on i can't write anything
please can anyone tell me what may be the problem i'm really confused

Sounds like there's something wrong in the way you are setting the CS pins. You might try looking at the earlier posts in this forum as there were example codes for this controller.

Author:  jijita [ Mon Aug 30, 2004 21:32 ]
Post subject: 

thank you henri for your help
i'll try the old posts

Page 1 of 1 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/