> > retlw 0x00
> >
> > ;*********************************************************
> > ;LCD ROUTINES
> > ;
> > ; LCDtx4 .. a routine to drive the HC44780 LCD in 4-bit
> > ; mode via a 3-wire interface.
> > ;
> > ; Data byte must already be in the CHARAC when the
> > ; routine is called. Data format ... D7 D6 D5 D4 RS x x x
> > ;This routine shifts a NIBBLE of Data into the LCD but does so
> > ;using a BYTE count. Data must be in the HIGH NIBBLE of the
> > ;charac register.
> > ;************************************************************
> > lcdtx4 movlw 0x08
> > IFDEF DEBUG
> > goto lcdout
> > ENDIF
> >
> > movwf count
> > bcf STATUS,C
> > bcf PORTB,CK
> > nop ;Rest between bit ops.
> > bsf PORTB,CH ;Initialise the Data port.
> > rotate rlf charac,1 ;Rotate the the Data thru CARRY, MSB
> > first.
> > btfss STATUS,C ;Data bit = 1?
> > bcf PORTB,CH ;No - send a zero
> > nop ;Rest between bit ops.
> > bsf PORTB,CK ;Clock the bit thru
> > nop
> > nop ;Rest between bit ops.
> > bcf PORTB,CK
> > decfsz count,1 ;Stepped down thru 8 bits?
> > goto rotate-1 ;No - keep clockin'
> > nop ;Rest between bit-ops.
> > bsf PORTB,EN ;Enable the LCD and
> > nop
> > nop
> > nop
> > nop ;transfer the Data.
> > bcf PORTB,EN
> > nop
> > lcdout bcf PORTB,CH ;Leave PORTB in a defined state. All
> > LOW.
> > retlw 0x00 ;Return to calling routine in PAGE #1
> >
> > ;**************************************************************
> > ;NIB_TX takes a Data byte and puts the LS nibble into the HIGH
> > ;nibble of the charac register. Data byte must be in the w register.
> > ;NIB_TX checks RS of the LCDflags register to determine CHARACTER or
> > ;COMMAND mode for the LCD
> > ;*****************************************************************
> > nib_tx movwf w2 ;w2 a VIRTUAL w register.. NOT w_
> > movlw b'11110000' ;Isolate the upper nibble and
> > andwf w2,0 ;retrieve it in w.
> > movwf charac ;Stash the processed byte in charac
> > btfsc LCDflag,RS ;RS=0? COMMAND mode?
> > bsf charac,3 ;No - set RS line for CHARACTER mode.
> > call lcdtx4 ;and send it to the LCD.
> > IFNDEF DEBUG
> > call DLY160 ;Wait 160 us till the LCD settles
> > ENDIF
> > swapf w2,1 ;Invert the H & L nibbles
> > movlw b'11110000'
> > andwf w2,0 ;Isolate the new upper 4 digits
> > movwf charac ;and store in charac register.
> > btfsc LCDflag,RS ;RS=0? COMMAND mode?
> > bsf charac,3 ;No - set RS line for CHARACTER mode.
> > call lcdtx4 ;Send'em to the LCD
> > IFNDEF DEBUG
> > call DLY160 ;Wait 160 uS till the LCD settles.
> > ENDIF
> > retlw 0x00 ;Go back to page #1 calling routine
> >
> > ;****************************************************************
> > ;DLY160 ... a one-loop, 160 usec (2.0MHz xtal) delay routine
> > ;Both LCD delay routines are called from PAGE #1 and return there.
> > ;DRTE : July 14, 1999
> > ;*****************************************************************
> > DLY160 movlw 0x05F ;0x050 Calculate C1= 4F (d79) for T=160
> > us)
> > movwf count_11
> > decfsz count_11,1
> > goto $-1
> > retlw 0x00
> >
> > ;****************************************************************
> > ;DLY_5 ... A two-loop, 5-m sec (2.0 MHz xtal) delay routine.
> > ;Both LCD delay routines are called from PAGE #1 and return there.
> > ;DRTE : July 14, 1999
> > ;****************************************************************
> > DLY_5 movlw 0x01F ;0x0F calculate C2=$0A (d10) for T = 5
> > msec
> > movwf count_12
> > movlw 0x0FF
> > movwf count_11
> > decfsz count_11,1
> > goto $-1
> > decfsz count_12,1
> > goto $-5
> > retlw 0x00
> >
> > ;**********************************************************
> > ;Main Programme .. begin from upper half of Bank #0. Turn
> > ;the interrupts OFF till we're configured.
> > ;**********************************************************
> > main ;bcf INTCON,GIE ;Switch off interrupts while we ...
> > BANK_0
> > call init ;Initialise the ports
> >
> > ;***********************************************************
> > ;Power up and configure the LCD
> > ;***********************************************************
> > pwr_up clrf LCDflag
> > bcf LCDflag,RS ;Clear RS.. COMMAND mode ENABLED
> > IFNDEF DEBUG
> > call DLY_5 ;Wait 15 ms after switch-on
> > call DLY_5
> > call DLY_5
> > call DLY_5
> > ENDIF
> >
> > movlw b'00110000' ;Write 0x03 to the LCD three
> > movwf charac ;times with suitable delays
> > call lcdtx4 ;RS=0 for COMMAND instructions
> > IFNDEF DEBUG
> > call DLY_5
> > ENDIF
> >
> > movlw b'00110000'
> > movwf charac
> > call lcdtx4
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw b'00110000'
> > movwf charac
> > call lcdtx4
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw b'00100000' ;4 bit interface
> > movwf charac
> > call lcdtx4
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > ;***************************************************************
> > ;The following instrucs require 2 only NIBBLE WRITES to the LCD.
> > ;Pass the parameters to the NIB_TX subroutine in w. NIB_TX will
> > ;call the lcd_tx4 subroutine. BEWARE the nest level!!
> > ;***************************************************************
> > movlw b'00101000' ;Write FUNCTION SET
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw b'00001110' ;Write ON/OFF
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw b'00000110' ;write ENT MODE
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw b'00000011' ;Return Cursor & LCD to home
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > ;************************************************************
> > ;Then display a "WAKE UP" message ...
> > ;************************************************************
> > wakeup movwf charac
> > IFNDEF DEBUG
> > call DLY_5
> > ENDIF
> >
> > clrf LCDflag
> > bsf LCDflag,RS ;Set RS=1 for CHARACTER mode.
> > ;Enable the 4 bit operating mode.
> > movlw lcd_I ;Load 'I' = B'01001001'
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw lcd_A ;Load 'A' = B'01000001'
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > movlw lcd_N ;Load 'N' = B'01001110'
> > call nib_tx
> > IFNDEF DEBUG
> > call DLY160
> > ENDIF
> >
> > setint nop ;Forget interrupts till the LCD
> > works!
> > ;BANK_1
> > ;movlw 0x0D
> > ;movwf OPTION_REG
> > ;BANK_0
> > ;clrf TMR0
> > ;movlw b'10011000' ;Enable the interrupts
> > ;movwf INTCON
> > ;clrf flags ;Initialise the flags
> >
> > goto wakeup ;Hold it here
> > end
> >
> > --
> >
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> > email
EraseMElistservspam_OUT
TakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body
> >
> >
> >
> >
> Sorry, I did not follow the whole part of code. However, as I recall,
> 74164 has a clear pin which should be considered.
>
> --
>
http://www.piclist.com hint: To leave the PICList
>
piclist-unsubscribe-request
spam_OUTmitvma.mit.edu
>
>