LCDInfo.com

http://www.lcdinfo.com
It is currently Mon Nov 25, 2024 2:09

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: wierd problem with lcd
PostPosted: Mon Aug 30, 2004 8:36 
Offline

Joined: Tue Aug 24, 2004 1:07
Posts: 11
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 8:39 
Offline

Joined: Tue Aug 24, 2004 1:07
Posts: 11
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


Top
 Profile  
 
PostPosted: Mon Aug 30, 2004 15:44 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 21:32 
Offline

Joined: Tue Aug 24, 2004 1:07
Posts: 11
thank you henri for your help
i'll try the old posts


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group