metals
Junior Member level 2
Hi!
The problem is..
I want this program to flash the LEDs on Port C. At the break from RB0 (falling edge) I want to write "Interrupt" on the LCD display and display it for a couple of seconds. I shall use the opportunity to have a pull-up resistors on Port B inputs.
I have this code down here but the only thing that is working is the LED lights
Can anyone see what I'm doing wrong?
The problem is..
I want this program to flash the LEDs on Port C. At the break from RB0 (falling edge) I want to write "Interrupt" on the LCD display and display it for a couple of seconds. I shall use the opportunity to have a pull-up resistors on Port B inputs.
I have this code down here but the only thing that is working is the LED lights
Can anyone see what I'm doing wrong?
Code:
List P=16F877 ;Processorangivelse
;*********************************************************
status equ 0x03
RP0 equ 0x05
intcon equ 0x0b
RB0flag equ 0x01
opt_reg equ 0x81
portB equ 0x06
portC equ 0x07
trisB equ 0x86
trisC equ 0x87
trisD equ 0x88
var1 equ 0x20
var2 equ 0x21
w_temp equ 0x22
status_temp equ 0x23
var3 equ 0x24
portD equ 0x08
ASCII equ 0x25
tab_pek equ 0x26
ganger equ 0x27
En equ 0x01
Z equ 0x02
PCL equ 0x02
Var_1 equ 0x28
Var_2 equ 0x29
;*****************************
org 0x00
clrf status
movlw 0x00
movwf 0x0A
goto init
;***********interrupt vector******************
org 0x04
goto interrupt
;************subroutines*****************
wait movlw 0xff
movwf var2
loop_2 movlw 0xff
movwf var1
loop_1 decfsz var1,1
goto loop_1
decfsz var2,1
goto loop_2
return
;*******interrupt subroutin**********************
interrupt movwf w_temp
swapf status,0
movwf status_temp
movlw 0x50
movwf var3
loop_3 call wait
decfsz var3,1
goto loop_3
bcf intcon,RB0flag
swapf status_temp,0
movwf status
swapf w_temp,1
swapf w_temp,0
retfie
;************************************************
waitms movlw 0x0A
movwf Var_2
loop2 movlw 0x64
movwf Var_1
loop1 decfsz Var_1,1
goto loop1
decfsz Var_2,1
goto loop2
return
;*****************************************
init clrw
movwf portD
movwf portB
bsf status,RP0
movwf trisD
movlw 0xff
movwf trisB
bcf opt_reg,7
bcf opt_reg,6
bcf status,RP0
bsf intcon,4
bsf intcon,7
clrw
movwf portD
bsf status,RP0
movwf trisD
bcf status,RP0
call LCDinit
;**************************************************
enable bsf portD,En
call wait
bcf portD,En
call wait
return
;**************************************************
main clrf tab_pek
movlw 0xAA
movwf portC
call wait
call wait
movlw 0x55
movwf portC
call wait
call wait
goto main
;**************************************************
again movfw tab_pek
call text
iorlw 0x00
btfsc status,Z
goto klar
call show_lcd
incf tab_pek,f
goto again
klar goto klar
text addwf PCL,f
retlw 'I'
retlw 'n'
retlw 't'
retlw 'e'
retlw 'r'
retlw 'r'
retlw 'u'
retlw 'p'
retlw 't'
show_lcd movwf ASCII
andlw 0xf0
movwf portD
bsf portD,0
call enable
swapf ASCII,w
andlw 0xf0
movwf portD
incf portD,f
call enable
return
movlw 0x00
movwf portC
call wait
movlw 0xff
movwf portC
call wait
goto main
LCDinit movlw 0xff
movwf ganger
loop3 call waitms
decfsz ganger,1
goto loop3
movlw 0x30
movwf portD
call enable
movlw 0x05
movwf ganger
loop4 call waitms
decfsz ganger,1
goto loop4
movlw 0x30
movwf portD
call enable
call wait
movlw 0x30
movwf portD
call enable
call waitms
movlw 0x20
movwf portD
call enable
call waitms
movlw 0x20
movwf portD
call enable
movlw 0x80
movwf portD
call enable
call waitms
movlw 0x00
movwf portD
call enable
movlw 0x10
movwf portD
call enable
call waitms
movlw 0x00
movwf portD
call enable
movlw 0x60
movwf portD
call enable
call waitms
movlw 0x00
movwf portD
call enable
movlw 0xe0
movwf portD
call enable
call waitms
return
;************************lcd_clear**********************
lcd_clear movlw 0x00
movwf portD
call LCD_Enable
movlw 0x10
movwf portD
call LCD_Enable
return
;************************LCD_Enable*************************
LCD_Enable bsf portD,En
call loop1
bcf portD,En
call loop1
return
end