;::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; Author: Rafael Franceschi :
; Date: 02/06/05 :
; Version: 2.7 :
; Title: Prueba 2 ( 7 modificaciones ) :
; Description: Toma la senal de entrada del puerto C :
; y la coloca en el puerto de salida B, :
; senales TTL (High and Low tanto en la :
; entrada como en la salida) :
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; You forgot to put the ff. line before the include.
LIST P=16F877
INCLUDE "P16F877.INC"
__CONFIG _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
;****************set up the constants****************
;*** Some of the constants are already defined in "PIC16F877.INC"
;STATUS EQU 03h
;TRISB EQU 86h
;TRISC EQU 87h
;PORTB EQU 06h
;PORTC EQU 07h
COUNT1 EQU 21h
COUNT2 EQU 22h
TEMP EQU 23h
ORG 0x00
GOTO CONFIGURATION
CONFIGURATION
BSF STATUS,5 ;Go to bank 1
CLRF TRISB ;Put 00 into TRISB - all pins set to output
MOVLW b'00001111' ;Put 255 into W
MOVWF TRISC ;Put 255 into TRISC - RC0/RC3 set as input
BCF STATUS,5 ;Come back to bank 0
CALL DIRECCION1
CALL DIRECCION2
CLRF PORTB
CLRF PORTC
START CALL INITIALIZE
CALL LOOP1
CALL ASSIGN
CALL ACT_ENABLE1
CALL ACT_ENABLE2
CALL LOOP2
GOTO START
;************Start of Delay 1***********************************
LOOP1 DECFSZ COUNT1,F ;Substract 1 from 255 - initial value of register 21h
GOTO LOOP1 ;If COUNT1 is Zero, jump this instruction
CALL DIRECCION1
RETURN
;***********Add Another OFF delay********************************
LOOP2 DECFSZ COUNT2,F ;Substract 1 from 255 - initial value of register 22h
GOTO LOOP2 ;If COUNT1 is Zero, jump this instruction
CALL DIRECCION2
RETURN
;************Subroutines Counters*********************************
DIRECCION1 MOVLW .50 ;Counter time - from "x" to zero
MOVWF COUNT1
RETURN
DIRECCION2 MOVLW .50 ;Counter time - from "x" to zero
MOVWF COUNT2
RETURN
;*************Initialize the ports and comands********************
INITIALIZE BSF PORTC,5
BSF PORTC,6
BSF PORTC,7
CLRF PORTB
CLRW
RETURN
;*************Enable the demuxs (2 at first)**********************
ACT_ENABLE1 BCF PORTC,5 ;Clears Enable Bit - Activates First Enable
RETURN
ACT_ENABLE2 BCF PORTC,6 ;Clears Enable Bit - Activates Second Enable
RETURN
;*************Assigning the Vectors*******************************
ASSIGN MOVF PORTC,W
ANDLW b'00001111'
MOVWF TEMP
MOVF PORTB,W
ANDLW b'11110000'
IORWF TEMP,W
MOVWF PORTB
RETURN
;**********************END of Program****************************
END