#include p16f84a.inc
D3 equ 21
D2 equ 22
D1 equ 23
org 00
goto start
org 04
goto int_routine
start bsf STATUS, 5
movlw B'00000000'
movwf TRISA
movlw B'00001000'
movwf TRISB
movlw B'00000000'
movwf OPTION_REG
bcf STATUS, 5
switch btfsc PORTB, 4
bsf PORTB, 3
call delay2
bcf PORTB, 3
goto switch
int_routine
LED
bsf PORTA, 1
call delay2
bcf PORTA, 1
call delay2
goto LED
delay1 movlw D'20'
movwf D3
movlw D'36'
movwf D2
movlw D'45'
movwf D1
decfsz D1
goto $ - 1
decfsz D2
goto $ - 5
decfsz D3
goto $ - 9
return
delay2 movlw D'10'
movwf D3
movlw D'25'
movwf D2
movlw D'32'
movwf D1
decfsz D1
goto $ - 1
decfsz D2
goto $ - 5
decfsz D3
goto $ - 9
return
end
list p=16F84A ; list directive to define processor
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; it tells it the oscillator type etc.
; user variables - ram area actually starts at 0x0C though 21 ok
D3 equ 21
D2 equ 22
D1 equ 23
org 00
goto start
org 04
; goto int_routine ; no routine to go to yet , so just return out.
retfie
start bsf STATUS, 5
movlw B'00000000'
movwf TRISA
movlw B'00001000'
movwf TRISB
movlw B'00000000'
movwf OPTION_REG ; ? which parameters are you selecting ?
bcf STATUS, 5
list p=16f84a
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
D3 equ 21
D2 equ 22
D1 equ 23
org 00
goto start
start bsf STATUS, 5
movlw B'00000000'
movwf TRISA
movlw B'00001000'
movwf TRISB
movlw B'00000000'
movwf OPTION_REG
bcf STATUS, 5
switch btfsc PORTB, 4
bsf PORTB, 3
call delay2
bcf PORTB, 3
goto switch
delay1 movlw D'20'
movwf D3
movlw D'36'
movwf D2
movlw D'45'
movwf D1
decfsz D1
goto $ - 1
decfsz D2
goto $ - 5
decfsz D3
goto $ - 9
return
list p=16f84a
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
D3 equ 21
D2 equ 22
D1 equ 23
org 00
goto start
LED
bsf PORTA, 1
call delay2
bcf PORTA, 1
call delay2
goto LED
delay2 movlw D'10'
movwf D3
movlw D'25'
movwf D2
movlw D'32'
movwf D1
decfsz D1
goto $ - 1
decfsz D2
goto $ - 5
decfsz D3
goto $ - 9
return
end
; *
;**********************************************************************
; *
; Files Required: P16F84A.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
; isr code can go here or be located as a call subroutine elsewhere
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
; remaining code goes here
list p=16F84A
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
w_temp equ 12
status_temp equ 13
org 00
goto start
org 04
goto int_routine
start bsf STATUS, RP0
movlw b'00001000'
movwf TRISB
clrf TRISA
movlw b'00000111'
movwf OPTION_REG
bcf STATUS, RP0
loop btfsc PORTB, 4
call delay
bcf PORTB, 4
bcf PORTB, 5
delay bsf PORTB, 5
; i do not know how to short cut way to calculate the 1s
dell btfss INTCON, T0IF
goto dell
bcf INTCON, T0IF
return
int_routine
movwf w_temp
movf STATUS, W
movwf status_temp
movf status_temp,W
movwf STATUS
swapf w_temp,F
swapf w_temp,W
retfie
end
list p=16F84A
#include p16f84a.inc
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
w_temp equ 12
status_temp equ 13
d1 equ 21
d2 equ 22
org 00
goto start
org 04
goto int_routine
timer bcf PORTA, 1
call delay
bsf PORTA, 1
call delay
goto timer
start bsf STATUS, RP0
movlw b'00001000'
movwf TRISB
clrf TRISA
bcf STATUS, RP0
loop btfsc PORTB, 3
call delay1
bcf PORTB, 4
goto loop
int_routine
movwf w_temp
incf status_temp, 1
movlw 0x0A
subwf w_temp, 0
btfss STATUS, 0
goto carry_on
goto clear
carry_on bcf INTCON, 0x01
movfw w_temp
retfie
clear clrf status_temp
bcf INTCON, 1
retfie
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
end
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,GIE
loop 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
end
;program omitted just below i try to add in
bsf INTCON, INTE
loop btfsc PORTB, 0
call delay
bcf PORTB, 7
delay bsf PORTB, 7
; the delay code omitted
return
end
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?