I only just works.. Lots wrong..i know it's work but iwant to let the value of tepretuer appear on LCD. i cant understand what you say abve, can you put your modify on the code here
I did this
Code:
PROCESSOR 16F877A
LIST P=16f877A
INCLUDE <P16F877A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
;:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:
;DECLARE VARIABLES
CNT EQU 0X28
TEMP EQU 0x29
DIGIT EQU 0x2A
TENS EQU 0x2B
;START PROGRAM
ORG 0 ;START @ ADDRESS 0
MAIN:
;CONFIGURE I/O PINS
BSF STATUS,RP0 ;SELECT BANK1 TO
BCF STATUS,RP1; ACCESS SFRs IN BANK1
CLRF TRISB ;CONGIGURE PORTB AS OUTPUT O/P
CLRF TRISD
;CLRF TRISC
BSF TRISA,0
MOVLW b'00000111'
MOVWF OPTION_REG
BCF STATUS,RP0 ; Selection of memory bank 0
CLRF PORTB ; Setting PORTB to "0000000"
CLRF PORTD ; Setting PORTD to "0000000"
CALL InitiateLCD
BSF STATUS,RP0; ACCESS SFRs IN BANK1
MOVLW B'10001110'
MOVWF ADCON1
BCF STATUS,RP0 ;RETURN BACK TO BANK0
MOVLW B'11000001'
MOVWF ADCON0
CALL DELAY_5ms
BEGIN:
BCF PORTD,RD0 ; Setting RS as 0 (Sends commands to LCD)
MOVLW b'11000000' ; Set cursor home
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
BSF PORTD,RD0 ; Setting RS as 1 (Sends data to LCD)
MOVF TEMP,W
CALL div
MOVF TENS,W
ADDLW 0x30
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVF DIGIT,W
ADDLW 0x30
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW 0xDF
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW 'C'
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW .28 ; load counter
MOVWF CNT
LOOP
DECFSZ CNT,f ; and delay 20us
GOTO LOOP
BSF ADCON0,GO ; start ADC..
wait
BTFSC ADCON0,GO ; ..and wait for finish
GOTO wait
BSF STATUS,RP0 ;RETURN BACK TO BANK1
MOVF ADRESL,W
BCF STATUS,RP0 ;RETURN BACK TO BANK0
MOVWF TEMP
BCF STATUS,C
RRF TEMP,W
MOVWF TEMP
SUBLW 0x14
BTFSS STATUS,C
goto More
;LESS
BCF STATUS,RP0 ;RETURN BACK TO BANK0
BCF PORTD,2
;MOVLW B'00000000'
;MOVWF PORTC
BCF PORTD,RD0 ; Setting RS as 0 (Sends commands to LCD)
MOVLW b'00000010' ; Set cursor home
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
BSF PORTD,RD0 ; Setting RS as 1 (Sends information to LCD)
CALL DELAY_5ms
MOVLW d'67' ; Print character "C"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'79' ; Print character "O"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'76' ; Print character "L"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'68' ; Print character "D "
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'32' ; Print character " "
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'60' ; Print character "< "
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'50' ; Print character "2"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'48' ; Print character "0"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'67' ; Print character "C"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
;BCF STATUS,RP0 ;RETURN BACK TO BANK0
GOTO BEGIN
More
BCF STATUS,RP0 ;RETURN BACK TO BANK0
BCF PORTD,2
; MOVLW B'01000000'
;MOVWF PORTC
BCF PORTD,RD0 ; Setting RS as 0 (Sends commands to LCD)
MOVLW b'00000010' ; Set cursor home
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
BSF PORTD,RD0 ; Setting RS as 1 (Sends information to LCD)
CALL DELAY_5ms
MOVLW d'87' ; Print character "W"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'65' ; Print character "A"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'82' ; Print character "R"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'77' ; Print character "M"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'32' ; Print character " "
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'62' ; Print character ">"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'50' ; Print character "2"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'48' ; Print character "0"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW d'67' ; Print character "C"
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
GOTO BEGIN
div
movwf DIGIT ; w contains the dividend
clrf TENS
movlw 0xA
subwf DIGIT,f
btfss STATUS,0 ; check for positive (Carry bit).
goto $+3 ; result is negative
incf TENS,f
goto $-4
addwf DIGIT,w
movwf DIGIT
RETURN
Enable BSF PORTD,1 ; E pin is high, (LCD is processing the incoming data)
NOP
BCF PORTD,1 ; E pin is low, (LCD does not care what is happening)
RETURN
DELAY_5ms
MOVLW .5 ; Delay of 5 ms
MOVWF TMR0
LOOP3 BTFSS INTCON,2
GOTO LOOP3
BCF INTCON,2
RETURN
InitiateLCD
BCF PORTD,RD0 ; Setting RS as 0 (Sends commands to LCD)
CALL DELAY_5ms
MOVLW b'00000001' ; Clearing display
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW b'00111000' ; Funtion set
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW b'00001100' ; Display on off
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
MOVLW b'00000110' ; Entry mod set
MOVWF PORTB
CALL Enable
CALL DELAY_5ms
RETURN
END
Notice I used ANSEL to get the precision.. When you use the ANSEH two vital bit were missing..