banksel ADRESL ;read and transfer
movf ADRESL,W ;AD resul to location
banksel ADRESH ;adres_low and adres_high
movwf adres_low ;respectively
movf ADRESH,W ;
movwf adres_high ;
bcf ADCON0,ADON ;AD module turned off
;*****************************************************************************
;This code block configures the ADC for polling,
;Uses Vdd and Vss as reference, Frc clock and AN2 input.
;
Initialise_ADC_left_AN2
BANKSEL TRISA ;
bsf TRISA,2 ;Set RA2 to input
BANKSEL ANSEL ;
bsf ANSEL,2 ;Set RA2 to analog
BANKSEL ADCON1 ;
movlw B'00000000' ;left justify ADFM = 0
movwf ADCON1 ;Vdd and Vss as Vref VCFG0 and VCFG1 = 0
BANKSEL ADCON0 ;
movlw B'11001001' ;ADC Frc clock,
movwf ADCON0 ;AN2, On
ADC_delay
movlw D'5' ;10us with an 8Mhz clock
movwf DELAY_ADC
ADC_delay_loop
decfsz DELAY_ADC, f
goto ADC_delay_loop
return
;*****************************************************************************
Read_ADC_AN2
bsf ADCON0,GO ;Start conversion
btfsc ADCON0,GO ;Is conversion done?
goto $-1 ;No, test again
BANKSEL ADRESH
movf ADRESH,W ;Read upper 8 bits
movwf ADC_RESULT_HI ;store in GPR space
BANKSEL ADRESL
movf ADRESL,W ;Read lower 2 bits
BANKSEL ADRESH
movwf ADC_RESULT_LO ;Store in GPR space
return
;*****************************************************************************
;***********config A/D module**************
;
;
;configure AD module
;
banksel ANSEL ;
;bcf STATUS,6h ;
;bsf STATUS,5h ;
;bank1 selected
;
clrf ANSEL ;
bsf ANSEL,an_ch ;
;RA4 is selected as analog channel
;
clrf ADCON1 ;
bsf ADCON1,ADFM ;
;AD result is right justified
;
bcf ADCON1,ADCS2 ;
;AD clock divide by 2 enabled
;
banksel ADCON0 ;
;back to bank0
;
clrf ADCON0 ;
bsf ADCON0,CHS_2 ;
;RA4 selected as analog input:configuring ADCON0
;
bSf ADCON0,ADCS1 ;##
bSf ADCON0,ADCS0 ;##
;INTRC is set as AD conversion clock
;
bsf ADCON0,ADON ;
;AD module turned on
;
;wait 15us
movlw 05h ;
movwf temp ;
delay_15us decfsz temp,F ;
goto delay_40us ;
;acquisition time elapsed
;
bsf ADCON0,go_done ;
;AD conversion starts now
;
check btfsc ADCON0,go_done ;
goto check ;
;
;above segment implement polling of go_done bit in
;every 100us
;read ad result register pair
banksel ADRESL ;read and transfer
movf ADRESL,W ;AD resul to location
banksel ADRESH ;adres_low and adres_high
movwf adres_low ;respectively
movf ADRESH,W ;
movwf adres_high ;
;
processor 16F88
include <p16f88.inc>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
;
;SPECIFY REGISTER_LCD
;
counter_l EQU 28H
counter_s EQU 29H
porta EQU 05h
portb EQU 06h
;
;bit_definition for lcd module
RS EQU 0h
RW EQU 1h
E EQU 2h
;---------------------------
;
;Specify register_AD_MODULE
;
ANSEL EQU 9bh
ADCON1 EQU 9fh
ADCON0 EQU 1fh
ADRESL EQU 9eh
ADRESH EQU 1eh
TRISA equ 85h
;
;bit_definition
;
an_ch equ 4h
RP_1 EQU 06H
RP_0 EQU 05H
ADFM EQU 07h
ADCS2 EQU 06h
ADCS1 EQU 07H
ADCS0 EQU 06H
go_done equ 02h
ADON equ 00h
CHS_0 EQU 03H
CHS_1 EQU 04H
CHS_2 EQU 05H
;------------------------------
;*****VARIABLES DEFINITION*******
;(binary to bcd conversion)
adres_low equ 27h
adres_high equ 26h
residue equ 25h
bcd_0 equ 20h
bcd_1 equ 21h
bcd_2 equ 22h
bcd_3 equ 23h
temp equ 24h
;---------CONSTANT DEFINITION---------
ascii_digi equ 30H
ascii_char1 equ 60H
ascii_char2 equ 70H
;PROGRAM
org 00h
;
;OSCILLATOR FREQUENCY MODE SELECTION
banksel OSCCON ;goto bank 1
bsf OSCCON,IRCF2 ;
bcf OSCCON,IRCF1 ;
bcf OSCCON,IRCF0 ;
bcf OSCCON,SCS1 ;
bcf OSCCON,SCS0 ;
;*********clock frequency set to 1MHz****************
banksel TRISA ;##back to bank0
;**************CONFIGURING PORTS*****************************
SETPORT movlw b'00010000' ;
movwf TRISA ;##
;tris porta ;
;RA0,1,2 are RS, RW and E respectively of lcd control
;lines, RA4 is the analog input for AD converter
;
movlw b'00000000' ;
movwf TRISB ;##
;all of the 8 pins of portb are configured as outputs.
;Only the higher nibble will be used to send data
;and command to the lcd module
;
;****************CONFIGURING PORT ENDS***********************
banksel porta ;
bcf porta,E ;
;clearing E
;
;************START OF INITIALISATION LCD***************
initio movlw 14h ;20
movwf temp ;times
loop call delay_1ms ;1ms
decfsz temp,F ;
goto loop ;
;A 20ms delay will give the lcd module enough time to
;stabilize itself on power up
;
bcf porta,RS ;
bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;the above segment sends the command
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 8-bit interface
movlw 05h ;
movwf temp ;
five_ms call delay_1ms ;
decfsz temp,F ;
goto five_ms ;
;5ms delay ref:HD44780 datasheet 8-bit interface
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 8-bit interface
;
movlw 46h ;
movwf temp ;
delay_200us decfsz temp,F ;
goto delay_200us ;
;200us delay ref:HD44780 datasheet 8-bit interface
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;again the same bit sequence is sent as before
;i.e 000011; 8-bit interface
;
fucntion_set bcf porta,RS ;
bcf porta,RW ;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;200US delay as per HD44780 datasheet
movwf temp ;
ALPHA decfsz temp,F ;
goto ALPHA ;
;DB4 is cleared to select 4-bit mode
;from now on every byte is sent in two nibbles and the
;the higher nibble is sent first
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;incorporates a delay of 200us
movwf temp ;ref: HD44780 datasheet
BETA decfsz temp,F ;
goto BETA ;
;the 'function set' command is sent again. the upper nibble
;being the same as before and the lower nibble specifying
;1-line and 5*7 pixel format i.e N=0 F=0
;ref:HD44780 datasheet
;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 80h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;
movwf temp ;delay 200us ref: HD44780 datasheet
GAMMA decfsz temp,F ;
goto GAMMA ;
;'display off' command 00001000 ref:HD44780 datasheet
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 60h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;delay 200us ref: HD44780 datasheet
movwf temp ;
DELTA decfsz temp,F ;
goto DELTA ;
;'display on' command 00000001 ref:HD44780 datasheet
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 0C0h ;
movwf portb ;
call enab_lcd ;
movlw 5h ;delay 5ms ref: HD44780 datasheet
movwf temp ;
MIKE call delay_1ms ;
decfsz temp,F ;
goto MIKE ;
;'entry mode' set
;
;*****************END OF INITIALIZATION*********************
;
;
;***********config A/D module**************
;
;
;configure AD module
;
banksel ANSEL ;
;bcf STATUS,6h ;
;bsf STATUS,5h ;
;bank1 selected
;
clrf ANSEL ;
bsf ANSEL,an_ch ;
;RA4 is selected as analog channel
;
clrf ADCON1 ;
bsf ADCON1,ADFM ;
;AD result is right justified
;
bcf ADCON1,ADCS2 ;
;AD clock divide by 2 enabled
;
banksel ADCON0 ;
;back to bank0
;
clrf ADCON0 ;
bsf ADCON0,CHS_2 ;
;RA4 selected as analog input:configuring ADCON0
;
bSf ADCON0,ADCS1 ;##
bSf ADCON0,ADCS0 ;##
;INTRC is set as AD conversion clock
;
bsf ADCON0,ADON ;
;AD module turned on
;
;wait 15us
movlw 05h ;
movwf temp ;
delay_15us decfsz temp,F ;
goto delay_40us ;
;acquisition time elapsed
;
bsf ADCON0,go_done ;
;AD conversion starts now
;
check btfsc ADCON0,go_done ;
goto check ;
;
;above segment implement polling of go_done bit in
;every 100us
;read ad result register pair
banksel ADRESL ;read and transfer
movf ADRESL,W ;AD resul to location
banksel ADRESH ;adres_low and adres_high
movwf adres_low ;respectively
movf ADRESH,W ;
movwf adres_high ;
;
;**********BINARY TO BCD CONVERSION CODE************
clrf bcd_0 ;
clrf bcd_1 ;
clrf bcd_2 ;
clrf bcd_3 ;
clrf residue ;
clrf temp ; clearing the registers finishes
ONE movf adres_high,F ;
btfss STATUS,Z ;
goto TWO ;
goto SIX ;
;
;
TWO movf adres_high,0 ;
sublw 01h ;
btfss STATUS,Z ;
goto THREE ;
movlw 02h ;
movwf bcd_2 ;
movlw 38h ;
movwf residue ;
goto SIX ;
;
;
THREE movf adres_high,0 ;
sublw 02h ;
btfss STATUS,Z ;
goto FOUR ;
movlw 05h ;
movwf bcd_2 ;
movlw 0ch ;
movwf residue ;
goto SIX ;
;
;
FOUR movlw 07h ;
movwf bcd_2 ;
movlw 44h ;
movwf residue ;
;
;
SIX movlw 64h ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto SIX_A ;
movf residue,W ;
addwf adres_low,F ;
goto SEVEN ;
;
SIX_A incf bcd_2,F ;
movf residue,W ;
addwf temp,F ;
movf temp,W ;
movwf adres_low ;
;
;
SEVEN movlw 64h ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto SEVEN_A ;
goto EIGHT ;
;
SEVEN_A incf bcd_2,F ;
movf temp,W ;
movwf adres_low ;
goto SEVEN ;
;
;
EIGHT movlw 0ah ;
subwf bcd_2,W ;
movwf temp ;
btfsc STATUS,C ;
goto EIGHT_A ;
goto NINE ;
;
EIGHT_A incf bcd_3,F ;
movf temp,W ;
movwf bcd_2 ;
;
;
NINE movlw 0ah ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto NINE_A ;
goto TEN ;
;
NINE_A incf bcd_1,F ;
movf temp,F ;
movwf adres_low ;
goto NINE ;
;
;
TEN movf adres_low,W ;
movwf bcd_0 ;
;FIN GOTO FIN ;
;
;**************DISPLAY BCD ON LCD*******************
;
bsf porta, RS ;
bcf porta, RW ;
show_bcd_3 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
swapf bcd_3,W ;
movwf portb ;
call enab_lcd ;
;
show_bcd_2 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
swapf bcd_2,W ;
movwf portb ;
call enab_lcd ;
;
show_bcd_1 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
swapf bcd_1,W ;
movwf portb ;
call enab_lcd ;
;
show_bcd_0 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
swapf bcd_0,W ;
movwf portb ;
call enab_lcd ;
;
show_p movlw ascii_char2 ;
movwf portb ;
call enab_lcd ;
movlw 0h ;
movwf portb ;
call enab_lcd ;
;
show_p2 movlw ascii_char2 ;
movwf portb ;
call enab_lcd ;
movlw 0h ;
movwf portb ;
call enab_lcd ;
;
show_b movlw ascii_char1 ;
movwf portb ;
call enab_lcd ;
movlw 20h ;
movwf portb ;
call enab_lcd ;
fin goto fin ;
;************************************************
;
;SUBROUTINES
;
enab_lcd bsf porta,E ;
nop ;
bcf porta,E ;
nop ;
return ;
;data is transferred when E goes from high to low
;
delay_1ms movlw 0ffh ;
movwf counter_s ;
point nop ;
decfsz counter_s,F ;
goto point ;
return ;
end ;
;
;SPECIFY REGISTER_LCD
;
counter_l EQU 28H
counter_s EQU 29H
porta EQU 05h ;Specified in p16f88.inc as PORTA
portb EQU 06h ;Specified in p16f88.inc as PORTB
;
;bit_definition for lcd module
RS EQU 0h
RW EQU 1h
E EQU 2h
;---------------------------
;
;Specify register_AD_MODULE
;
ANSEL EQU 9bh ;Specified in p16f88.inc
ADCON1 EQU 9fh ;Specified in p16f88.inc
ADCON0 EQU 1fh ;Specified in p16f88.inc
ADRESL EQU 9eh ;Specified in p16f88.inc
ADRESH EQU 1eh ;Specified in p16f88.inc
TRISA equ 85h ;Specified in p16f88.inc
;
;bit_definition
;
an_ch equ 4h
RP_1 EQU 06H ;Specified in p16f88.inc
RP_0 EQU 05H ;Specified in p16f88.inc
ADFM EQU 07h ;Specified in p16f88.inc
ADCS2 EQU 06h ;Specified in p16f88.inc
ADCS1 EQU 07H ;Specified in p16f88.inc
ADCS0 EQU 06H ;Specified in p16f88.inc
go_done equ 02h ;Specified in p16f88.inc
ADON equ 00h ;Specified in p16f88.inc
CHS_0 EQU 03H ;Specified in p16f88.inc
CHS_1 EQU 04H ;Specified in p16f88.inc
CHS_2 EQU 05H ;Specified in p16f88.inc as CHS2
I cannot get your code to run using Oshonsoft.??
It also reports a missing delay_400us routine.
It also reports a missing delay_400us routine.
wait 15us
movlw 05h ;
movwf temp ;
delay_15us decfsz temp,F ;
goto delay_40us ;
processor 16F88
include <p16f88.inc>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
;
;SPECIFY REGISTER_LCD
;
counter_l EQU 28H
counter_s EQU 29H
porta EQU 05h
portb EQU 06h
;
;bit_definition for lcd module
RS EQU 0h
RW EQU 1h
E EQU 2h
;---------------------------
;
;Specify register_AD_MODULE
;
;
;bit_definition
;
an_ch equ 4h
RP_1 EQU 06H
RP_0 EQU 05H
ADFM EQU 07h
ADCS2 EQU 06h
ADCS1 EQU 07H
ADCS0 EQU 06H
go_done equ 02h
ADON equ 00h
CHS_0 EQU 03H
CHS_1 EQU 04H
CHS_2 EQU 05H
;------------------------------
;*****VARIABLES DEFINITION*******
;(binary to bcd conversion)
adres_low equ 27h
adres_high equ 26h
residue equ 25h
bcd_0 equ 20h
bcd_1 equ 21h
bcd_2 equ 22h
bcd_3 equ 23h
temp equ 24h
;---------CONSTANT DEFINITION---------
ascii_digi equ 30H
ascii_char1 equ 60H
ascii_char2 equ 70H
;PROGRAM
org 00h
;
;OSCILLATOR FREQUENCY MODE SELECTION
banksel OSCCON ;goto bank 1
clrf OSCTUNE ;center frequency
clrf OSCCON ;
movlw b'11101010' ;
movwf OSCCON ;
;*********clock frequency set to 4MHz****************
banksel TRISA ;##back to bank0
;**************CONFIGURING PORTS*****************************
SETPORT movlw b'00010000' ;
movwf TRISA ;##
;tris porta ;
;RA0,1,2 are RS, RW and E respectively of lcd control
;lines, RA4 is the analog input for AD converter
;
movlw b'00000000' ;
movwf TRISB ;##
;all of the 8 pins of portb are configured as outputs.
;Only the higher nibble will be used to send data
;and command to the lcd module
;
;****************CONFIGURING PORT ENDS***********************
banksel porta ;
bcf porta,E ;
;clearing E
;
;************START OF INITIALISATION LCD***************
initio movlw 14h ;20
movwf temp ;times
loop call delay_1ms ;1ms
decfsz temp,F ;
goto loop ;
;A 20ms delay will give the lcd module enough time to
;stabilize itself on power up
;
bcf porta,RS ;
bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;the above segment sends the command
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 8-bit interface
movlw 05h ;
movwf temp ;
five_ms call delay_1ms ;
decfsz temp,F ;
goto five_ms ;
;5ms delay ref:HD44780 datasheet 8-bit interface
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 8-bit interface
;
movlw 46h ;
movwf temp ;
delay_200us decfsz temp,F ;
goto delay_200us ;
;200us delay ref:HD44780 datasheet 8-bit interface
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 30h ;
movwf portb ;
call enab_lcd ;
;again the same bit sequence is sent as before
;i.e 000011; 8-bit interface
;
fucntion_set bcf porta,RS ;
bcf porta,RW ;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;200US delay as per HD44780 datasheet
movwf temp ;
ALPHA decfsz temp,F ;
goto ALPHA ;
;DB4 is cleared to select 4-bit mode
;from now on every byte is sent in two nibbles and the
;the higher nibble is sent first
;
; bcf porta,RS ;
; bcf porta,RW ;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;incorporates a delay of 200us
movwf temp ;ref: HD44780 datasheet
BETA decfsz temp,F ;
goto BETA ;
;the 'function set' command is sent again. the upper nibble
;being the same as before and the lower nibble specifying
;1-line and 5*7 pixel format i.e N=0 F=0
;ref:HD44780 datasheet
;
movlw 20h ;
movwf portb ;
call enab_lcd ;
movlw 80h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;
movwf temp ;delay 200us ref: HD44780 datasheet
GAMMA decfsz temp,F ;
goto GAMMA ;
;'display off' command 00001000 ref:HD44780 datasheet
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 60h ;
movwf portb ;
call enab_lcd ;
movlw 46h ;delay 200us ref: HD44780 datasheet
movwf temp ;
DELTA decfsz temp,F ;
goto DELTA ;
;'display on' command 00000001 ref:HD44780 datasheet
movlw 00h ;
movwf portb ;
call enab_lcd ;
movlw 0C0h ;
movwf portb ;
call enab_lcd ;
movlw 5h ;delay 5ms ref: HD44780 datasheet
movwf temp ;
MIKE call delay_1ms ;
decfsz temp,F ;
goto MIKE ;
;'entry mode' set
;
;*****************END OF INITIALIZATION*********************
;
;
;***********config A/D module**************
;
;
;configure AD module
;
banksel ANSEL ;
clrf ADRESL ;##
;bank1 selected
;
clrf ANSEL ;
bsf ANSEL,04H ;
;RA4 is selected as analog channel
;
;RA4 set as analog input pin
;
clrf ADCON1 ;
movlw b'11000000' ;
movwf ADCON1 ;
;AD result is right justified
;AD clock divide by 2 enabled?
;setting reference voltage as Vdd and Vss
;
banksel ADCON0 ;
movlw b'10100000' ;
movwf ADCON0 ;
clrf ADRESH ;##
;back to bank0
;RA4 selected as analog input:configuring ADCON0
;Fosc/8 is set as AD conversion clock
;
bsf ADCON0,ADON ;
;AD module turned on
;
;wait 25us acquisition time
movlw 08h ;
movwf temp ;
delay_25us decfsz temp,F ;
goto delay_25us ;
;acquisition time elapsed
;
bsf ADCON0,go_done ;
;AD conversion starts now
;
CHECK btfsc ADCON0,go_done ;
goto CHECK ;
;polling of go_done bit in
;read ad result register pair
banksel ADRESL ;read and transfer
movf ADRESL,W ;AD resul to location
banksel ADRESH ;adres_low and adres_high
movwf adres_low ;respectively
movf ADRESH,W ;
movwf adres_high ;
bcf ADCON0,ADON ;AD module turned off
;**********BINARY TO BCD CONVERSION CODE************
clrf bcd_0 ;
clrf bcd_1 ;
clrf bcd_2 ;
clrf bcd_3 ;
clrf residue ;
clrf temp ; clearing the registers finishes
ONE movf adres_high,F ;
btfss STATUS,Z ;
goto TWO ;
goto SIX ;
;
;
TWO movf adres_high,0 ;
sublw 01h ;
btfss STATUS,Z ;
goto THREE ;
movlw 02h ;
movwf bcd_2 ;
movlw 38h ;
movwf residue ;
goto SIX ;
;
;
THREE movf adres_high,0 ;
sublw 02h ;
btfss STATUS,Z ;
goto FOUR ;
movlw 05h ;
movwf bcd_2 ;
movlw 0ch ;
movwf residue ;
goto SIX ;
;
;
FOUR movlw 07h ;
movwf bcd_2 ;
movlw 44h ;
movwf residue ;
;
;
SIX movlw 64h ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto SIX_A ;
movf residue,W ;
addwf adres_low,F ;
goto SEVEN ;
;
SIX_A incf bcd_2,F ;
movf residue,W ;
addwf temp,F ;
movf temp,W ;
movwf adres_low ;
;
;
SEVEN movlw 64h ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto SEVEN_A ;
goto EIGHT ;
;
SEVEN_A incf bcd_2,F ;
movf temp,W ;
movwf adres_low ;
goto SEVEN ;
;
;
EIGHT movlw 0ah ;
subwf bcd_2,W ;
movwf temp ;
btfsc STATUS,C ;
goto EIGHT_A ;
goto NINE ;
;
EIGHT_A incf bcd_3,F ;
movf temp,W ;
movwf bcd_2 ;
;
;
NINE movlw 0ah ;
subwf adres_low,W ;
movwf temp ;
btfsc STATUS,C ;
goto NINE_A ;
goto TEN ;
;
NINE_A incf bcd_1,F ;
movf temp,F ;
movwf adres_low ;
goto NINE ;
;
;
TEN movf adres_low,W ;
movwf bcd_0 ;
;FIN GOTO FIN ;
;
;**************DISPLAY BCD ON LCD*******************
;
bsf porta, RS ;
bcf porta, RW ;
show_bcd_3 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
swapf bcd_3,W ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_bcd_2 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
swapf bcd_2,W ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_bcd_1 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
swapf bcd_1,W ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_bcd_0 movlw ascii_digi ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
swapf bcd_0,W ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_p movlw ascii_char2 ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
movlw 0h ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_p2 movlw ascii_char2 ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
movlw 0h ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
;
show_b movlw ascii_char1 ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
movlw 20H ;
movwf portb ;
call enab_lcd ;
call delay_1ms ;
fin goto fin ;
;************************************************
;
;SUBROUTINES
;
enab_lcd bsf porta,E ;
nop ;
bcf porta,E ;
nop ;
return ;
;data is transferred when E goes from high to low
;
delay_1ms movlw 0ffh ;
movwf counter_s ;
point nop ;
decfsz counter_s,F ;
goto point ;
return ;
end ;
;
1. according to my understanding the ad clock frequencey Fosc/8 should be sufficient ref: page 118, datasheet 16F88. but doing so generate an error of Tad less than 1.6us. until i reduce it to Fosc/64 the message keep on showing.
For the 4MHz check, write a simple test loop that toggles a PORT pin every 1 sec. If you have a scope you could measure it or use a 390R resistor and a LED on that toggled pin.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?