Anda di halaman 1dari 3

;****************************************************************************** ; This

file is a basic template for assembly code for a PIC18F4550. Copy * ; this file into your
project directory and modify or add to it as needed. * ; * ; The PIC18FXXXX architecture
allows two interrupt configurations. This * ; template code is written for priority
interrupt levels and the IPEN bit * ; in the RCON register must be set to enable priority
levels. If IPEN is * ; left in its default zero state, only the interrupt vector at 0x008 will
* ; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not * ; be
needed. * ; * ; Refer to the MPASM User's Guide for additional information on the * ;
features of the assembler. * ; * ; Refer to the PIC18FXX50/XX55 Data Sheet for
additional * ; information on the architecture and instruction set. * ; *
;****************************************************************************** ; * ;
Filename: * ; Date: 19/01/15 * ; File Version: 1.0 * ; * ; Author: * ; ; *
;****************************************************************************** ; * ; Files
required: P18F4550.INC * ; *
;****************************************************************************** LIST
P=18F4550, F=INHX32 ;directive to define processor #include <P18F4550.INC>
;processor specific variable definitions
;****************************************************************************** ;
;****************************************************************************** ;Variable
definitions ; These variables are only needed if low priority interrupts are used. ; More
variables may be needed to store other special function registers used ; in the interrupt
routines. ;******************************************************************************
;Reset vector ; This code will start executing when a reset occurs. RESET_VECTOR ORG
0 goto Main ;go to start of main code
;******************************************************************************
;****************************************************************************** ;Start of
main program ; The main program code is placed here.
ORG 0x1000;direccion del programa en ensamblador
Main:
segundos EQU 0X10
minutos EQU 0X11
horas equ 0x12
seg equ 0x13
min equ 0x14
hr equ 0x15
call Cfgptos ;Subrutina para configurar puertos I/O

inicio
movlw 0x3b
movwf segundos
movwf minutos
movlw 0x0C
movwf horas
clrf PORTB
clrf PORTD
clrf PORTA
movlw 0x00
movwf min
movlw 0x00
movwf hr
movlw 0x00
movwf seg
Ciclo:
bcf INTCON,2
call CfgTMR0
seg_rutina
movf seg,W
cpfslt segundos
goto aumento_seg
aumento_minutos
incf min
cpfseq minutos
goto limpio_seg
aumento_horas

incf hr
cpfseq horas
goto limpio_minutos
goto inicio
aumento_seg incf seg movwf PORTB goto loop ;goto seg_rutina limpio_seg movlw 0x00
movwf seg CLRF
PORTB MOVF min,W movwf PORTD GOTO Ciclo limpio_minutos movlw 0x00 movwf min
movwf PORTD incf hr movwf PORTA goto seg_rutina loop: btfss INTCON,2 goto loop goto
Ciclo CfgTMR0
movlw 0x48
movwf TMR0H
movlw 0xE5
movwf TMR0L
movlw 0x87
movwf T0CON
return ;****************************************************************************** ;
Cfgptos - Subrutina para configurar los puertos de E/S
Cfgptos movlw 0x0F ;Configura las entradas mutiplexadas con el movwf ADCON0
;convertidor A/D como entradas digitales. movlw 0x07 ;Configura las entradas
multiplexadas con movwf CMCON ;los comparadores como entradas digitales. movlw
0x00 ;Configura todas las lneas del movwf TRISA ;puerto A como entradas. movlw
0x00 ;Configura todas las lneas del movwf TRISD ;puerto A como entradas. movlw
0x00 ;Configura todas las lneas del movwf TRISB ;puerto A como entradas. return
;****************************************************************************** ;End of
program END

Anda mungkin juga menyukai