emperror123
New Member
as i understand the question is mean they have active low switch connected to RB3 and when it is pressed, active high led will on for 1 second, in between 1 sec, any switch press will not happen anything. 2nd is LED in RA1 will on / off 0.25second will be in ISR. both use RC oscillator and 800kHz
now i am require to modified the below coding to add RB0 as switch and RB7 as out put but unfortunate unable to function after i been modified, how should i do? and it need to use INTCON, INTE to do it
after i modified my RA1 will keep blinking non stop which is i set 0.25 on / off
now i am require to modified the below coding to add RB0 as switch and RB7 as out put but unfortunate unable to function after i been modified, how should i do? and it need to use INTCON, INTE to do it
Code:
list p=16F84A
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
W_ISR_TEMP equ 12
STATUS_ISR_TEMP equ 13
d1 equ 21
d2 equ 22
org 00
goto start
org 04
movwf W_ISR_TEMP
swapf STATUS,W
clrf STATUS
movwf STATUS_ISR_TEMP
bcf INTCON,T0IF
btfss PORTA,1
goto ledon
bcf PORTA,1
goto isrend
ledon bsf PORTA,1
isrend swapf STATUS_ISR_TEMP,W
movwf STATUS
swapf W_ISR_TEMP,F
swapf W_ISR_TEMP,W
retfie
timer bcf PORTA, 1
call delay
bsf PORTA, 1
call delay
goto timer
start bsf STATUS, RP0
movlw b'00001000'
movwf TRISB
clrf TRISA
movlw B'00000110' ; set up timer0 , bits 0-2 prescaler 1:128, bit3 prescaler to Timer 0, bit5 using main internal clock 800khz/4 = 200khz !
movwf OPTION_REG
bcf STATUS, RP0
bsf INTCON,T0IE ; enable interrupts
bsf INTCON, INTE
BSF INTCON,GIE
loop btfsc PORTB, 0
call delay3
bcf PORTB, 7
bsf PORTB,4
call delay1
bcf PORTB, 4
CALL delay1
goto loop
delay movlw 0x0F
movwf d1
movlw 0x28
movwf d2
Delay0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay0
;2 cycles
goto $+1
return
delay1 movlw 0x3F
movwf d1
movlw 0x9D
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay0
;2 cycles
goto $+1
return
delay3 bsf PORTB, 7
; delay code omitted, due to i not sure nid add in since it doesnt mention it
return
end
after i modified my RA1 will keep blinking non stop which is i set 0.25 on / off
Last edited: