Escolar Documentos
Profissional Documentos
Cultura Documentos
6CM3
Electrónica Digital
31-Mayo-2016
DIAGRAMA DE FLUJO
MAIN
CONFIGURAR PUERTOS
CONFIGURAR INTERRUPCION
SLEEP
ISR_INT0
CALL ABRIR
CONTADOR=15
CALL RETARDO
CONTADOR=0?
CALL CERRAR
LIMPIAR BANDERAS
RETFIE
ABRIR
LATA=LETRA A
AUX=12
LATD=EEh
CALL RETARDO
LATD<<
CALL RETARDOM
AUX=0?
RETURN
CERRAR
AUX=12
LATD=EEh
CALL RETARDO
LATD>>
CALL RETARDOM
AUX=0?
LATA=00h
RETURN
RETARDO
CONFIGURAR TIMER
ENCENDER EL TIMER
TMR0IF=1?
APAGAR TIMER
LIMPIAR BANDERA
RETURN
RETARDOM
CONFIGURAR TIMERM
ENCENDER EL TIMER
TMR0IF=1?
APAGAR TIMER
LIMPIAR BANDERA
RETURN
CONFIGURAR TIMER
LIMPIAR BANDERAS
RETURN
CONFIGURAR TIMERM
LIMPIAR BANDERAS
RETURN
CODIGO
;******************************************************************************
; 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: Display A mediante interrupciones *
; Date: 29/05/16 *
; File Version: 1.0 *
; *
; Author: Ing. Alejandro Vicente Lugo Silva *
; Company: Acad. Computación ICE - ESIME Zac. *
; *
;******************************************************************************
; *
; Files required: P18F4550.INC *
; *
;******************************************************************************
;******************************************************************************
;Configuration bits
RESET_VECTOR ORG 0
;******************************************************************************
;******************************************************************************
;Start of main program
; The main program code is placed here.
ORG 0x1000 ;Inicio de la ISR del Reset
Inicio
goto Main
;******************************************************************************
ORG 0X1008 ;Inicio de la ISR de alta prioridad
goto ISR_INT0
retfie
;******************************************************************************
ORG 0x1018 ;Inicio de la ISR de baja prioridad
retfie
;******************************************************************************
ciclo
sleep
goto ciclo
; end of main
;******************************************************************************
; Confpuertos- Define las líneas de E/S
;******************************************************************************
Confpuertos
movlw 0x0F ;Configuración de los puertos en modo digital
movwf ADCON1
clrf TRISD ;Puerto D son salidas todos las terminales.
clrf LATD ;Salidas apagadas inicialmente por seguridad.
CLRF TRISA ;Puerto A son salidas todos las terminales.
MOVLW 0XFF
MOVWF LATD ;Salidas apagadas inicialmente por seguridad.
return
;******************************************************************************
; Conf_Int- Configuración del modo de operación del timer 0
;******************************************************************************
Conf_Int
movlw 0xB0 ;Habilitas int_ext y timer 1011 0000
movwf INTCON
return
;******************************************************************************
; Conf_Timer- Configuración del modo de operación del timer 0
;******************************************************************************
Conf_Timer
movlw 0x07 ; configuracion medio segundo 0000 0110
movwf T0CON
movlw 0x48
movwf TMR0H
movlw 0xE5
movwf TMR0L
bcf INTCON,TMR0IF ;cero las banderas de la int
return
;******************************************************************************
; ISR_INT0
;******************************************************************************
ISR_INT0
CALL ABRIR
MOVLW 0X0E; 0X0F
MOVWF CONTADOR
MAMA
CALL RETARDO
DECFSZ CONTADOR
GOTO MAMA
CALL CERRAR
bcf INTCON,TMR0IF
bcf INTCON,INT0IF
MOVLW 0XFF
MOVWF LATD
retfie
RETARDO
call Conf_Timer
bsf T0CON,7 ;Enciendes el timer
cicloISR ; flanco de subida
btfss INTCON,TMR0IF ; compara y salta si es 1
goto cicloISR
bcf T0CON,7 ;apagas el timer
bcf INTCON,TMR0IF
RETURN
ABRIR
movlw 0xFF ;letra A en el puerto D
movwf LATA
MOVLW D'12';PASOS PARA 90°
MOVWF AUX
MOVLW 0XEE
MOVWF LATD
CALL RETARDOM
MOVERI RLNCF LATD
CALL RETARDOM
DECFSZ AUX
GOTO MOVERI
RETURN
CONFIGT0M
movlw 0x03 ; configuracion de 0000 0011
movwf T0CON ; Configuracion para 30ms
movlw 0x6D ; configuracion d'54286'=D40E
movwf TMR0H
movlw 0x84
movwf TMR0L
bcf INTCON,2
return
RUTINAM
BSF T0CON,7
UNO BTFSS INTCON,TMR0IF
GOTO UNO
bcf INTCON,TMR0IF
bcf INTCON,7
RETURN
;******************************************************************************
;End of program
END
DIAGRAMA