Você está na página 1de 29

Ejercicios resueltos de Microcontroladores NIVEL 0 1.

Hacer un programa en Assembler para encender y apagar un led conectado al pin RA0 del Microcontrolador 16F84A. Solucin:

LIST P=16F84A INCLUDE <P16F84A.INC> CONT1 EQU 0X20 CONT2 EQU 0X21 ORG 0x00 GOTO INICIO ORG 0x05 INICIO bsf STATUS,RP0 clrf TRISA bcf STATUS,RP0 ENCLED bsf PORTA,0 call RETARDO bcf PORTA,0 call RETARDO GOTO ENCLED RETARDO movlw 0xff movwf CONT1 REP1 movlw 0xff movwf CONT2 REP2 decfsz CONT2,1 GOTO REP2 decfsz CONT1,1 GOTO REP1 RETURN END 2.

C1
1nF

X1 C2
1nF

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R2
330

R1
10k

D1

Hacer un programa en Assembler de tal manera que por el puerto B se obtenga el dato complementado de del dato que ingresa por el puerto A del Microcontrolador PIC 16f84A. Solucin

LIST P=16f84A INCLUDE "P16F84A.INC" COMPLEMENTO EQU 0X0C ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 Movlw 0XFF Movwf TRISA Clrf TRISB Bcf STATUS,5 BUCLE movf PORTA,0 Movwf COMPLEMENTO Comf COMPLEMENTO,0 Movwf PORTB GOTO BUCLE END

C1
1nF

0 1 0 1 0
X1 U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

C2
1nF

R1
10k

1 0 1 0 1

3.

Hacer un cdigo en Assembler para obtener por el puerto B el dato del puerto A multiplicado por tres Solucin:

LIST P=16F84A INCLUDE "P16F84A.INC" SUMA1 EQU 0X0C SUMA2 EQU 0X0D ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 movlw 0XFF movwf TRISA clrf TRISB bcf STATUS,5 clrf PORTA clrf PORTB ;. BUCLE movf PORTA,0 addwf PORTA,0 movwf SUMA1 movf PORTA,0 addwf SUMA1,0 movwf PORTB GOTO BUCLE END

1 1 0 0 0
U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

4.

Hacer un cdigo en Assembler para obtener por el puerto B el dato del puerto A intercambiado los nibles alto y bajo. Solucin:

1 0 0 1 0 0 0 0

LIST P=16F84A INCLUDE <P16F84A.INC> ;... INTERCAMB EQU 0X0C ORG 0X00 GOTO INICIO ORG 0X05 ;..... INICIO bsf STATUS,5 movlw 0xff movwf TRISA clrf TRISB bcf STATUS,5 ; BUCLE movf PORTA,0 movwf INTERCAMB swapf INTERCAMB,0 movwf PORTB GOTO BUCLE END

R2 R3 R4 R5 R6
10k 10k 10k 10k 10k

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10 R11R12 R13 R14


330 330 330 330 330 330 330 330

5.

Hacer un cdigo en Assembler para obtener por el puerto B el dato del puerto A desplazando un bit hacia la izquierda, por la derecha entra un 1 ejemplo A= xxx11001 entonces B=xx110011. Solucin:

LIST P=16F84A INCLUDE <P16F84A.INC> AUX EQU 0X0C ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 movlw 0xff movwf TRISA clrf TRISB bcf STATUS,5 clrf PORTB BUCLE movf PORTA,0 movwf AUX rlf AUX,1 bsf AUX,0 movf AUX,0 movwf PORTB GOTO BUCLE END

R2 R3 R4 R5 R6
10k 10k 10k 10k 10k

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10 R11R12 R13 R14


330 330 330 330 330 330 330 330

6.

Hacer un cdigo en Assembler para rotar hacia la izquierda un bit activado en 1 visualizara por el puerto B. Solucin:

LIST P=16F84A INCLUDE <P16F84A.INC> CONTA1 EQU 0X0C CONTA2 EQU 0X0D ORG 0X00 GOTO INICIO INICIO bsf STATUS,5 clrf TRISB bcf STATUS,5 movlw 0x01 movwf PORTB BUCLE call RETARDO rlf PORTB,1 GOTO BUCLE RETARDO movlw 0xff movwf CONTA1 r1 movlw 0xff movwf CONTA2 r2 decfsz CONTA2,1 GOTO r2 decfsz CONTA1,1 GOTO r1 return END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10R11R12R13R14
330 330 330 330 330 330 330 330

7.

Hacer un cdigo en Assembler para rotar hacia la derecha dos bits activados en 11 visualizar por el puerto B.

Solucin: ; inicio del programa LIST P=16F84A INCLUDE <P16F84A.INC> ; Declaracin de registros de propsito general CONTA1 EQU 0X0C CONTA2 EQU 0X0D ; Ubicacin en la memoria de programa ORG 0X00 GOTO INICIO ORG 0X05 ; Configuracin de puertos INICIO bsf STATUS,5 clrf TRISB bcf STATUS,5 ; Carga de dato al puerto B clrf PORTB movlw 0xc0 movwf PORTB ; inicio del bucle infinito BUCLE call RETARDO rrf PORTB,1 GOTO BUCLE ; retardo para desplazamiento a la derecha RETARDO movlw 0xff movwf CONTA1 r1 movlw 0xff movwf CONTA2 r2 decfsz CONTA2,1 GOTO r2 decfsz CONTA1,1 GOTO r1 return END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10R11R12R13R14
330 330 330 330 330 330 330 330

8.

Hacer un cdigo en Assembler para un contador binario ascendente visualizar por el puerto B.

Solucin: ; Inicio del programa LIST P=16F84A INCLUDE <P16F84A.INC> ; Declaracin de registros de propsito general CONTA1 EQU 0X0F CONTA2 EQU 0X10 ; Ubicacin en la memoria de programa ORG 0x00 GOTO INICIO ORG 0x05 ; Configuracin de puertos INICIO bsf STATUS,5 clrf TRISB bcf STATUS,5 ; Poner a cero el puerto B clrf PORTB CALL RETARDO ; Incrementar puerto B BUCLE incf PORTB,1 CALL RETARDO GOTO BUCLE ; Retardo para conteo ascendente RETARDO clrf CONTA1 REP1 clrf CONTA2 REP2 incfsz CONTA2,1 GOTO REP2 incfsz CONTA1,1 GOTO REP1 RETURN END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10R11R12R13R14
330 330 330 330 330 330 330 330

9.

Hacer un cdigo en Assembler para un contador binario descendente visualizar por el puerto B. Solucin:

; Inicio del programa LIST P=16F84A INCLUDE <P16F84A.INC> ; Declaracin de registros de propsito general CONTA1 EQU 0X0F CONTA2 EQU 0X10 ; Ubicacin en la memoria de programa ORG 0x00 GOTO INICIO ORG 0x05 ; Configuracin de puertos INICIO bsf STATUS,5 clrf TRISB bcf STATUS,5 ; Cargar datos al puerto B movlw 0xff movwf PORTB CALL RETARDO ; Inicio del bucle infinito BUCLE decf PORTB,1 CALL RETARDO GOTO BUCLE ; Retardo para conteo descendente RETARDO clrf CONTA1 REP1 clrf CONTA2 REP2 incfsz CONTA2,1 GOTO REP2 incfsz CONTA1,1 GOTO REP1 RETURN END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R1
10k

R7 R8 R9 R10R11R12R13R14
330 330 330 330 330 330 330 330

10. Hacer un cdigo en Assembler para luces secuenciales llamado desde una tabla mostrar por el puerto B. Solucin: LIST P=16F84A INCLUDE <P16F84A.INC> CONTA1 EQU 0X0C CONTA2 EQU 0X0D CONTA3 EQU 0X0E BYTE EQU 0X0F U1 ORG 0X00 GOTO INICIO 16 OSC1/CLKIN RA0 ORG 0X05 15 OSC2/CLKOUT RA1 INICIO bsf STATUS,5 RA2 clrf PORTB 4 MCLR RA3 bcf STATUS,5 RA4/T0CKI clrf PORTB clrf BYTE RB0/INT BUCLE btfsc BYTE,4 RB1 clrf BYTE RB2 movf BYTE,0 RB3 call TABLA movwf PORTB RB4 ; Rutina del retardo RB5 movlw D'20 RB6 movwf CONTA1 RB7 LOOP1 movwf D'20 PIC16F84A movwf CONTA2 LOOP2 movlw D'50 movwf CONTA3 LOOP3 decfsz CONTA3,1 GOTO LOOP3 decfsz CONTA2,1 GOTO LOOP2 decfsz CONTA1,1 GOTO LOOP1 incf BYTE,1 GOTO BUCLE ; Retorno de w con el valor binario correspondiente. TABLA addwf PCL,1 retlw B'10000001' retlw B'01000010' retlw B'00100100' retlw B'00011000' retlw B'00100100' retlw B'01000010' retlw B'10000001' retlw B'11111111' retlw B'00000000' retlw B'11111111' retlw B'00000000' retlw B'11111111' retlw B'11001100' retlw B'00110011' retlw B'10101010' retlw B'01010101' END

17 18 1 2 3 6 7 8 9 10 11 12 13

1 1 0 0 1 1 0 0

Nivel 1 1. Mediante un display alfanumrico mostrar en forma descendente las letras del alfabeto de Z a A. Solucin: LIST P=16F877A INCLUDE <P16F877A.INC> AUX1 EQU 0X22 AUX2 EQU 0X23 ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 clrf TRISB clrf TRISC bcf STATUS,5 BUCLE clrf PORTB clrf PORTC movlw b'00001001' movwf PORTB movlw b'00010001' movwf PORTC CALL RETARDO movlw b'01000000' movwf PORTB movlw b'00001001' movwf PORTC CALL RETARDO movlw b'01000000' movwf PORTB movlw b'00010101' movwf PORTC CALL RETARDO movlw b'00110110' movwf PORTB movlw b'00010100' movwf PORTC CALL RETARDO movlw b'00110000' movwf PORTB movlw b'00010001' movwf PORTC CALL RETARDO movlw b'00111110' movwf PORTB movlw b'00000000' movwf PORTC CALL RETARDO movlw b'10000001' movwf PORTB movlw b'00001000' movwf PORTC CALL RETARDO

;Z
13 14 2 3 4 5 6 7 8 9 10 1

U3
OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

;Y

;X

RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A SRCFILE=..\ejem1.hex

;W

;V

;U

;T

movlw b'00101101' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00110011' movwf PORTB movlw b'00100110' movwf PORTC CALL RETARDO movlw b'00100111' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00110011' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00111111' movwf PORTB movlw b'00000000' movwf PORTC CALL RETARDO movlw b'01110110' movwf PORTB movlw b'00000100' movwf PORTC CALL RETARDO movlw b'01110110' movwf PORTB movlw b'00000001' movwf PORTC CALL RETARDO movlw b'00111000' movwf PORTB movlw b'00000000' movwf PORTC CALL RETARDO movlw b'00110000' movwf PORTB movlw b'00100101' movwf PORTC CALL RETARDO movlw b'00011110' movwf PORTB movlw b'00000000' movwf PORTC CALL RETARDO movlw b'10001001' movwf PORTB movlw b'00001000' movwf PORTC CALL RETARDO

;S

;R

;Q

;P
U3
13 14 2 3 4 5 6 7 8 9 10 1 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

;O

;N

RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A SRCFILE=..\ejem1.hex

;M

;L

;K

;J

;I

movlw b'00110110' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00111101' movwf PORTB movlw b'00000010' movwf PORTC CALL RETARDO movlw b'00110001' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00111001' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00011110' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00111001' movwf PORTB movlw b'00000000' movwf PORTC CALL RETARDO movlw b'00111100' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO movlw b'00110111' movwf PORTB movlw b'00100010' movwf PORTC CALL RETARDO GOTO BUCLE

;H

;G

;F

U3
13 14 2 3 4 5 6 7 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

;E

8 9 10 1

RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A SRCFILE=..\ejem1.hex

;D

;C

;B

;A

; Retardo para visualizar el zyx RETARDO clrf AUX1 REP1 clrf AUX2 REP2 incfsz AUX2,1 GOTO REP2 decfsz AUX1,1 GOTO REP1 return END

2. Por el puerto B mostrar las siguientes operaciones: portB.0 = portC.0 and portC.1, portB.1= portC.2 or portC.3, portB.2 = portC.4 xor portC.5. Solucin:
LIST P=16F877 INCLUDE "P16F877.INC" BIT0 EQU 0X20 BIT1 EQU 0X21 BIT2 EQU 0X22 ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 movlw b'11111111' movwf TRISC clrf TRISB bcf STATUS,5 movfw PORTC movwf BIT0 movwf BIT1 movwf BIT2 movlw b'00000011' andwf BIT0,1 movlw b'00000011' subwf BIT0,0 btfss STATUS,2 GOTO PUERTOB0 bsf PORTB,0 GOTO ORRR PUERTOB0 bcf PORTB,0 GOTO ORRR ORRR movlw b'00001100' andwf BIT1,1 movlw b'00000000' subwf BIT1,1 btfss STATUS,2 GOTO PUERTOB1 bcf PORTB,1 GOTO XORRR PUERTOB1 bsf PORTB,1 GOTO XORRR XORRR movlw b'00110000' andwf BIT2,1 movlw b'00000000' subwf BIT2,0 btfss STATUS,2 GOTO MAYOR GOTO IGUAL IGUAL bcf PORTB,2 GOTO INICIO MAYOR movlw b'00110000' subwf BIT2,0 btfss STATUS,2 GOTO DIFERENTECERO GOTO IGUAL DIFERENTECERO bsf PORTB,2 GOTO INICIO END

U1
13 14 2 3 4 5 6 7 8 9 10 1 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RA0/AN0 RB3/PGM RA1/AN1 RB4 RA2/AN2/VREF-/CVREF RB5 RA3/AN3/VREF+ RB6/PGC RA4/T0CKI/C1OUT RB7/PGD RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

0 1 1
5 4 3 2

AND OR XOR 1 0

1 0

1 0

0 1

3. Segn el estado de los interruptores RA0 y RA1, activar los leds RB0-RB7 conectados a la puerta B, conforme a la siguiente tabla de la verdad:

Solucin: LIST P=16F84A INCLUDE "P16F84A.INC" ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 movlw 0xff movwf TRISA clrf TRISB bcf STATUS,5 movlw b'00000000' subwf PORTA,0 btfss STATUS,2 GOTO UNO GOTO IMPRIME1 movlw b'10101010' movwf PORTB GOTO INICIO movlw b'00000001' subwf PORTA,0 btfss STATUS,2 GOTO DOS GOTO IMPRIME2 movlw b'01010101' movwf PORTB GOTO INICIO movlw b'00000010' subwf PORTA,0 btfss STATUS,2 GOTO TRES GOTO IMPRIME3 movlw b'00001111' movwf PORTB GOTO INICIO movlw b'11110000' movwf PORTB GOTO INICIO END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

IMPRIME1 UNO

IMPRIME2 DOS

IMPRIME3 TRES

4. Una lmpara conectada en RB0 se controla mediante dos interruptores conectados en RA1 y RA2. Cuando cualquiera de los interruptores cambie de estado, la lmpara tambin lo har. Solucin: List P=16F84 INCLUDE "P16F84.INC" TEMP equ 0x0c ORG 0x00 GOTO INICIO ORG 0x05 INICIO clrf bsf clrf movlw movwf bcf clrf PORTB STATUS,5 TRISB b'00000011' TRISA STATUS,5 TEMP

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

LOOP movf PORTA,W andlw b'00000011' movwf TEMP btfsc STATUS,Z GOTO APAGAR movlw b'00000001' subwf TEMP,0 btfsc STATUS,2 GOTO ENCENDER movlw b'00000010' subwf TEMP,W btfsc STATUS,2 GOTO ENCENDER APAGAR bcf PORTB,0 GOTO LOOP

ENCENDER bsf PORTB,0 GOTO LOOP end

5. Una lmpara conectada en RB1 se controla mediante 3 interruptores conectados en RA1, RA2 y RA3. Cuando 2 interruptores estn en estado alto se activara la salida RB1, en otra condicin la salida estar apagado Solucin: RA1 RA2 RA3 RB0 ; ; 0 ; 0 ; 0 ; 0 ; 1 ; 1 ; 1 ; 1 ; ; ; ZONA DE DATOS 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 1 0

__CONFIG _CP_OFF&_WDT_OFF&_PWRTE_ON&_XT_OSC; configuracin para el ; Grabador LIST p=16F84A ; Procesador INCLUDE <P16F84A.INC> ; definicin de los operando utilizados NUM EQU d'1' ; ZONA DE CODIGOS ORG 0 ; el programa comienza en la direccin 0 de memoria de programa INICIO bsf movlw movwf movlw movwf bcf PRINCIPAL movf andlw call movwf goto salida addwf retlw retlw retlw retlw retlw retlw retlw retlw END STATUS,RP0 b'00000000' TRISB b'00000111' TRISA STATUS,RP0 PORTA,W b'000000111' salida PORTB PRINCIPAL PCL,F b'0' b'0' b'0' b'1' b'0' b'1' b'1' b'0'

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

6. Efecto de luces tipo Auto Fantstico con un 16F84A por el puerto b, RB0 a RB7 Solucin: LIST P=16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D ORG 0X00 GOTO INICIO INICIO bsf STATUS,5 clrf TRISB bcf STATUS,5 movlw b'10000000' movwf PORTB CALL RETARDO movlw b'01000000' movwf PORTB CALL RETARDO movlw b'00100000' movwf PORTB CALL RETARDO movlw b'00010000' movwf PORTB CALL RETARDO movlw b'00001000' movwf PORTB CALL RETARDO movlw b'00000100' movwf PORTB CALL RETARDO movlw b'00000010' movwf PORTB CALL RETARDO movlw b'00000001' movwf PORTB CALL RETARDO movlw b'00000010' movwf PORTB CALL RETARDO movlw b'00000100' movwf PORTB CALL RETARDO movlw b'00001000' movwf PORTB CALL RETARDO RETARDO

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

clrf CONTA1 REP1 clrf CONTA2 REP2 incfsz CONTA2,1 GOTO REP2 incfsz CONTA1,1 GOTO REP1 RETURN END

7. Disee un contador de 8 bits, que se incrementa cada vez que se pulsa P (RA0). Visualice el resultado por el puerto B. Activar un led (RA1), cuando el contador llegue a D120 y apagarlo cuando llegue a D200. Repetir el ciclo. Solucin: List P=16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D CONTADOR EQU 0X0E ORG 0x00 GOTO INICIO ORG 0x05 INICIO bsf STATUS,5 bsf TRISA,0 bcf TRISA,1 clrf TRISB bcf STATUS,5 clrf CONTADOR clrf PORTB movf CONTADOR,0 movwf PORTB EXPLORA btfsc PORTA,0 goto EXPLORA goto SI SI incf CONTADOR,1 Call RETARDO movf CONTADOR,0
PIC16F84A

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 17 18 1 2 3 6 7 8 9 10 11 12 13
1

movwf PORTB sublw .120 btfss STATUS,Z goto VALOR2 bsf PORTA,1 goto EXPLORA VALOR2 movf CONTADOR sublw .200 btfss STATUS,Z goto EXPLORA bcf PORTA,1 clrf CONTADOR clrf PORTB goto EXPLORA RETARDO movlw 0xff movwf CONTA1 REP1 movlw 0xff movwf CONTA2 REP2 decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN End

8. Utilizando un PIC16F84 realice un Juego de Luces de 8 leds, donde por medio de un Pulsador de Inicio el Juego se coloque en funcionamiento. El Juego se comportara de la siguiente manera: Los leds inicialmente se encendern solo uno a la vez en secuencia, de DERECHA a IZQUIERDA y de IZQUIERDA a DERECHA; Este proceso lo realizara 7 veces, donde al terminar pasara a la siguiente secuencia que se comportara de la siguiente manera: El secuenciador ser de 8 leds donde encendern uno por uno, y al estar todos encendidos se apagaran; Este Proceso se realizara 5 veces. Luego todo este proceso se realizara nuevamente. Nota: Utilice las instrucciones RLF y RRF. Solucin: LIST P=16F84A INCLUDE <P16F84A.INC> AUX1 EQU 0X0C AUX2 EQU 0X0D CONTA1 EQU 0X0E CONTA2 EQU 0X0F ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 clrf TRISB bsf TRISA,0 bcf STATUS,5 clrf PORTB BUCLE1 btfss PORTA,0 GOTO BUCLE1 clrf PORTB clrf AUX1 clrf AUX2 bsf PORTB,0 BUCLE2 CALL RETARDO rlf PORTB,1 btfss PORTB,0 GOTO BUCLE2 BUCLE4 rrf PORTB,1 CALL RETARDO btfss PORTB,0 GOTO BUCLE4 incf AUX1 movlw 0x07 subwf AUX1,0 btfss STATUS,2 GOTO BUCLE2 BUCLE3 clrf PORTB incf AUX2 bsf PORTB,0 CALL RETARDO bsf PORTB,1 CALL RETARDO bsf PORTB,2 CALL RETARDO bsf PORTB,3 CALL RETARDO bsf PORTB,4 CALL RETARDO

RETARDO REP1 REP2

bsf PORTB,5 CALL RETARDO bsf PORTB,6 CALL RETARDO bsf PORTB,7 CALL RETARDO movlw 0x05 subwf AUX2,0 btfss STATUS,2 GOTO BUCLE3 clrf PORTB GOTO BUCLE1 movlw 0xff movwf CONTA1;CONTADOR1 = 0XFF movlw 0xff movwf CONTA2;CONTADOR2 = 0XFF decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

9. Utilizando un PIC16F84 realice un Contador de 4 en 4 que cuando llegue a 40 realice el encendido de una alarma por medio del Pin RA4, luego de ello se debe realizar el contador de 4 en 4 de forma descendente y al terminar se debe realizar todo el proceso nuevamente Solucin: LIST P=16f84A INCLUDE "P16f84A.INC" CONTADOR1 EQU 0X20 CONTADOR2 EQU 0X21 AUX1 EQU 0X22 AUX2 EQU 0X23 ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf bcf clrf bcf clrf VUELTA STATUS,RP0 TRISA,4 TRISB STATUS,RP0 PORTB clrf movlw addwf CALL movf sublw STATUS .4 PORTB,1 RETARDO PORTB,0 .40

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

VOLVER

btfss STATUS,Z GOTO VUELTA CALL RETARDO bsf PORTA,4 movlw .4 subwf PORTB,1 CALL RETARDO movf PORTB,0 sublw .4 btfss STATUS,Z GOTO VOLVER bcf PORTA,4 GOTO VUELTA

0 0 0 1 1 0 0 0

RETARDO REP1 REP2

movlw 0xff movwf AUX1 movlw 0xff movwf AUX2 decfsz AUX2,1 goto REP2 decfsz AUX1,1 GOTO REP1 RETURN END

10. Utilizando un PIC16F877 realice la captacin de dos nmeros de 4 bits, los cuales ambos son suministrados por el Puerto B. Estos nmeros deben de ser comparados para lo siguiente: Si N1=N2 encender una alarma. (Por RA0) Si N1>N2 realizar la suma de estos nmeros para luego realizar un contador desde este valor hasta su desbordamiento. (Mostrar por el Puerto A) Si N1<N2 realizar el complemento a 1 del nmeroN2. (Mostrar por el Puerto A) El nmero N1 son los 4 bits menos significativos del Puerto B y el numero N2 son los 4 bits ms significativos del Puerto B. Solucin:
LIST P=16F877 INCLUDE "P16f877.INC" NUMERO1 EQU 0X20 NUMERO2 EQU 0X21 CONTA1 EQU 0X23 CONTA2 EQU 0X24 ORG 0X00 INICIO bsf STATUS,5 movlw 0xFF movwf TRISB clrf TRISC bcf TRISA,0 bcf STATUS,5 BUCLE clrf PORTA movlw 0x0F andwf PORTB,0 movwf NUMERO1 movlw 0xF0 andwf PORTB,0 movwf NUMERO2 swapf NUMERO2,1 movfw NUMERO1 subwf NUMERO2,0 btfss STATUS,0 GOTO MAYOR GOTO MENOR GOTO BUCLE MAYOR movfw NUMERO1 addwf NUMERO2,0 movwf PORTC INCRE CALL RETARDO incfsz PORTC GOTO INCRE GOTO FINAL RETARDO movlw 0xff movwf CONTA1 REP1 movlw 0xff movwf CONTA2 REP2 decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN IMPRIME bsf PORTA,0' GOTO BUCLE MENOR movfw NUMERO1 subwf NUMERO2,0 btfsc STATUS,2 GOTO IMPRIME comf NUMERO2,0 movwf PORTC GOTO BUCLE FINAL movlw b'00000000' movwf PORTC GOTO BUCLEL END

NUMERO 1

U1
13 14 1 OSC1/CLKIN OSC2/CLKOUT MCLR/Vpp/THV RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

2 3 4 5 6 7 8 9 10

RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RE0/AN5/RD RC2/CCP1 RE1/AN6/WR RC3/SCK/SCL RE2/AN7/CS RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877

1 1 0 0

NUMERO2

1 1 1 0 1 0 0 0 1 1 1 1

11. Utilizando un PIC16F84, realice un contador binario de 5 a 55 por medio de leds, en bucle infinito. Solucin: LIST P=16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D ORG 0x00 GOTO INICIO ORG 0X05 INICIO bsf movlw movwf bcf clrf STATUS,5 .0 PORTB STATUS,5 PORTB
16 15 4

U1
OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

BUCLE BUCLE1

movlw .5 movwf PORTB CALL RETARDO incf PORTB movlw .55 subwf PORTB,0 btfss STATUS,Z GOTO BUCLE1 CALL RETARDO GOTO BUCLE

0 1 1 1 1 0 0 0

RETARDO REP1 REP2

movlw 0xff movwf CONTA1 movlw 0xff movwf CONTA2 decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN END

12. Utilizando un PIC16F84 realice un secuenciador de 8 leds de izquierda a derecha y de derecha a izquierda por el Puerto B. Se deben ir encendiendo los leds de 3 en 3 en forma secuencial. (Mientras tres leds estn encendidos todos los dems estn apagados). El secuenciador a la izquierda se realiza por medio de la activacin de un switch colocado en RA0 en activo bajo. El secuenciador a la derecha se realiza por la activacin de un switch colocado en RA1 en activo bajo. En otros estados de la entrada la salida ser apagado. Solucin:
LIST P = 16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 clrf TRISB movlw 0XFF movwf TRISA bcf STATUS,5 BUCLE btfsc PORTA,0 GOTO BUCLE2 btfsc PORTA,1 GOTO IZQUIERDA GOTO BUCLE3 BUCLE2 btfsc PORTA,1 GOTO BUCLE3 GOTO DERECHA BUCLE3 clrf PORTB GOTO BUCLE RETARDO movlw 0xff movwf CONTA1 REP1 movlw 0xff movwf CONTA2 REP2 decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN DERECHA movlw B'00000000' movwf PORTB CALL RETARDO movlw B'11100000' movwf PORTB CALL RETARDO movlw B'01110000' movwf PORTB CALL RETARDO movlw B'00111000' movwf PORTB CALL RETARDO movlw B'00011100' movwf PORTB CALL RETARDO movlw B'00001110' movwf PORTB CALL RETARDO movlw B'00000111' movwf PORTB

R11
10k

R2
10k

IZQUIERDA A DERECHA

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

DERECHA A IZQUIERDA

R3
330

R4
330

R5
330

R6
330

R7
330

R8
330

R9
330

R10
330

D1

D2

D3

D4

D5

D6

D7

D8

LED-GREEN LED-GREEN LED-GREEN LED-GREEN LED-GREEN LED-GREEN LED-GREEN LED-GREEN

IZQUIERDA

CALL RETARDO movlw B'00000000' movwf PORTB CALL RETARDO GOTO BUCLE movlw B'00000000' movwf PORTB CALL RETARDO movlw B'00000111' movwf PORTB CALL RETARDO movlw B'00001110' movwf PORTB CALL RETARDO movlw B'00011100' movwf PORTB CALL RETARDO movlw B'00111000' movwf PORTB CALL RETARDO movlw B'01110000' movwf PORTB CALL RETARDO movlw B'11100000' movwf PORTB CALL RETARDO movlw B'00000000' movwf PORTB CALL RETARDO GOTO BUCLE END

13. Se tienen 2 switch que de acuerdo a las combinaciones de estos se realizaran uno de los siguientes procesos: Si el SW1 = 1 y SW2 =0 se realiza la intermitencia de 8 leds 10 veces. Si el SW1=0 y el SW2=1 encender 8 leds de 2 en 2 de adentro hacia fuera y de afuera hacia adentro. Este proceso se debe ejecutar 5 veces. Si el SW1=0 y el SW2=0 el valor actual del puerto debe mantenerse. Si el SW1=1 y el SW2=1 se realizara un contador de 6 en 6 hasta 36. Solucin:
LIST P=16F84A INCLUDE "P16F84A.INC" DIEZ EQU 0X0C CONTA1 EQU 0X0D CONTA2 EQU 0X0E CINCO EQU 0X0F SEIS EQU 0X10 ORG 0X00 GOTO INICIO INICIO bsf STATUS,5 movlw 0XFF movwf TRISA clrf TRISB bcf STATUS,5 movlw D'10 movwf DIEZ movlw D'5 movwf CINCO movlw D'6 movwf SEIS

BUCLE movlw b'01' subwf PORTA,0 btfss STATUS,2 GOTO DOS IMPRIME movlw b'11111111' movwf PORTB CALL RETARDO clrf PORTB CALL RETARDO decfsz DIEZ GOTO IMPRIME GOTO BUCLE DOS movlw b'10' subwf PORTA,0 btfss STATUS,2 GOTO TRES GOTO IMPRIME1 IMPRIME1 movlw b'00011000' movwf PORTB call RETARDO movlw b'00100100' movwf PORTB call RETARDO movlw b'01000010' movwf PORTB call RETARDO movlw b'10000001' movwf PORTB call RETARDO movlw b'01000010' movwf PORTB call RETARDO movlw b'00100100' movwf PORTB call RETARDO movlw b'00011000' movwf PORTB call RETARDO decfsz CINCO GOTO IMPRIME1 GOTO BUCLE TRES movlw b'00' subwf PORTA,0 btfss STATUS,2 GOTO IMPRIME2 GOTO BUCLE IMPRIME2 clrf PORTB IMPRIME3 movlw D'6 addwf PORTB,1 call RETARDO decfsz SEIS,1 GOTO IMPRIME3 GOTO BUCLE RETARDO movlw 0xff movwf CONTA1 REP1 movlw 0xff movwf CONTA2 REP2 decfsz CONTA2,1 goto REP2 decfsz CONTA1,1 goto REP1 RETURN END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

0 1 0 0 0 0 1 0

14. Por medio de la activacin de 1 de 4 suitch, realizara lo siguiente: Si RA0=1 rota a la izquierda con solo 1 led encendido. Si RA1=1 rota a la derecha con solo 1 led encendido. Si RA2=1 rota a la izquierda dejando encendido cada led. Si RA3=1 rota a la derecha dejando encendido cada led La muestra se realiza por el puerto B. Solucin: LIST P=16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D ORG 0X00 ORG 0X05 bsf STATUS,5 movlw 0xFF movwf TRISA clrf TRISB bcf STATUS,5 BUCLE movlw b'0001' subwf PORTA,0 btfss STATUS,2 GOTO SEGUNDO movlw b'00000001' movwf PORTB IMPRIMIR1 CALL RETARDO rlf PORTB,1 btfss STATUS,0 GOTO IMPRIMIR1 GOTO BUCLE SEGUNDO movlw b'0010' subwf PORTA,0 btfss STATUS,2 GOTO TERCERO movlw b'10000000' movwf PORTB IMPRIMIR2 CALL RETARDO rrf PORTB,1 btfss STATUS,0 GOTO IMPRIMIR2 GOTO BUCLE TERCERO movlw b'0100' subwf PORTA,0 btfss STATUS,2 GOTO CUARTO movlw b'00000000' movwf PORTB CALL RETARDO movlw b'00000001' movwf PORTB CALL RETARDO movlw b'00000011' movwf PORTB CALL RETARDO movlw b'00000111' movwf PORTB CALL RETARDO movlw b'00001111'

movwf PORTB CALL RETARDO movlw b'00011111' movwf PORTB CALL RETARDO movlw b'00111111' movwf PORTB CALL RETARDO movlw b'01111111' movwf PORTB CALL RETARDO movlw b'11111111' movwf PORTB CALL RETARDO GOTO BUCLE CUARTO movlw b'1000' subwf PORTA,0 btfss STATUS,2 GOTO BUCLE movlw b'00000000' movwf PORTB CALL RETARDO movlw b'10000000' movwf PORTB CALL RETARDO movlw b'11000000' movwf PORTB CALL RETARDO movlw b'11100000' movwf PORTB CALL RETARDO movlw b'11110000' movwf PORTB CALL RETARDO movlw b'11111000' movwf PORTB CALL RETARDO movlw b'11111100' movwf PORTB CALL RETARDO movlw b'11111110' movwf PORTB CALL RETARDO movlw b'11111111' movwf PORTB CALL RETARDO GOTO BUCLE RETARDO movlw 0xff movwf CONTA1 REP1 movlw 0xff movwf CONTA2 REP2 decfsz CONTA2,1 goto REP2 decfsz CONTA1,1 goto REP1 RETURN END

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

R5
10k

0 0 1 1 1 1 1 1

15. Leer las tres lneas ms bajas del puerto A, que fijan el nmero de leds que se iluminan en la salida. A si por ejemplo si lee el dato xx101 (cinco) en los leds conectados al puerto B se iluminara el cdigo 00011111 encendindose cinco leds. Solucin: LIST P=16F84A INCLUDE "P16F84A.INC" CONTA1 EQU 0X0C CONTA2 EQU 0X0D AUX EQU 0X0E ORG 0x00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 bsf TRISA,0 bsf TRISA,1 bsf TRISA,2 clrf TRISB bcf STATUS,5 clrf PORTA clrf PORTB BUCLEmovf PORTA,0 movwf AUX btfsc STATUS,Z GOTO CERO Movlw b'00000001' Subwf AUX,0 btfsc STATUS,Z GOTO UNO Movlw b'00000010' subwf AUX,0 btfsc STATUS,Z GOTO DOS Movlw b'00000011' Subwf AUX,0 btfsc STATUS,Z GOTO TRES movlw b'00000100' subwf AUX,0 btfsc STATUS,Z GOTO CUATRO movlw b'00000101' subwf AUX,0 btfsc STATUS,Z GOTO CINCO Movlw b'00000110' subwf AUX,0 btfsc STATUS,Z GOTO SEIS ;******* SIETE movlw b'01111111' movwf PORTB GOTO BUCLE

CERO UNO DOS TRES CUATRO CINCO SEIS

movlw b'0000000' movwf PORTB GOTO BUCLE movlw b'00000001' movwf PORTB GOTO BUCLE movlw b'00000011' movwf PORTB GOTO BUCLE movlw b'00000111' movwf PORTB GOTO BUCLE movlw b'00001111' movwf PORTB GOTO BUCLE movlw b'00011111' movwf PORTB GOTO BUCLE movlw b'00111111' movwf PORTB GOTO BUCLE movlw 0xff movwf CONTA1;CONTADOR1 = 0XFF movlw 0xff movwf CONTA2;CONTADOR2 = 0XFF decfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 RETURN END

RETARDO REP1 REP2

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 PIC16F84A 17 18 1 2 3 6 7 8 9 10 11 12 13

1 0 1 1 1 1 1 1 0 0 0

16. Hacer un programa para 16F84 de tal manera que a travs de dos displays pueda visualizarse un contador decimal de 0 99 ascendentes. Solucin: ;INICIO DEL PROGRAMA list p = 16F84A INCLUDE <P16F84A.INC> CONTA1 EQU 0X0C CONTA2 EQU 0X0D AUX EQU 0X0E ORG 0X00 GOTO INICIO ORG 0X05 INICIO bsf STATUS,5 clrf TRISA clrf TRISB bcf STATUS,5 clrf clrf BUCLE AUMENTO incf PORTB call RETARDO movf PORTB,0 sublw 0X09 btfss STATUS,Z GOTO AUMENTO incf PORTA clrf PORTB movf PORTA,0 sublw 0x0A btfss STATUS,Z GOTO AUMENTO clrf PORTA GOTO BUCLE clrf CONTA1 clrf CONTA2 incfsz CONTA2,1 GOTO REP2 decfsz CONTA1,1 GOTO REP1 return END
PIC16F84A

U1
16 15 4 OSC1/CLKIN OSC2/CLKOUT MCLR RA0 RA1 RA2 RA3 RA4/T0CKI RB0/INT RB1 RB2 RB3 RB4 RB5 RB6 RB7 17 18 1 2 3 6 7 8 9 10 11 12 13

PORTA PORTB

RETARDO REP1 REP2

Você também pode gostar