Kod: Markera allt
list p=16f88 ; list directive to define processor
#include <p16F88.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x71 ; variable used for context saving
status_temp EQU 0x72 ; variable used for context saving
pclath_temp EQU 0x73 ; variable used for context saving
;Wait subroutine
count1 equ 0x0C ; wait counter ls digit file register C
count2 equ 0x0D ; wait counter ms digit file register D
same equ 1
;**********************************************************************
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
movf PCLATH,W ; move PCLATH register into W register
movwf pclath_temp ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
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
BSF STATUS, RP0 ; Select Bank1
MOVLW B'11111000'
MOVWF TRISA
MOVLW B'00000000' ; Value used to initialize data direction
MOVWF TRISB ;
MOVLW B'00000000'
MOVWF ANSEL
MOVLW B'01100000' ;osc=4MHz
MOVWF OSCCON
BCF STATUS, RP0 ;Select Bank 0
;Led off
MOVLW 0xFF
MOVWF PORTA
Loop
BCF PORTA, 1
call wait
BCF PORTA, 0
call wait
goto Loop
wait
movlw 0xA ; load count1 with decimal 200
movwf count1
d1 movlw 0xA ; load count2 with decimal 200
movwf count2 ; shorten these for the simulator
BCF PORTA,2
d2 decfsz count2,same ; decrement and skip next line if zero
goto d2 ; if not zero
BSF PORTA,2
decfsz count1,same ; decrement count1 if count2 is zero
goto d1 ; do inside loop again if count2 nz
return
Kod: Markera allt
BCF PORTA,2
d2 decfsz count2,same ; decrement and skip next line if zero
goto d2 ; if not zero
BSF PORTA,2