Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
El objetivo de esta práctica es usar lenguaje ensamblador para conocer tres algoritmos tomados de
la web: primero es generar números pseudo aleatorios de 40 bits, segundo convertir los doce bits
más bajos de dicho número a tres BCDs mismos que se exhibirán en sendos displays de siete
segmentos que serán conectados a cuatro decoders 74LS48 para cátodo común y tercero crear una
rutina que tome 1.2 segundos, hecha con software. Si alguno de los displays es de ánodo común,
usar el 74LS47 para él.
SW1
Title
LFSR DOUBLE DABBLE 12 bits
Size Document Number Rev
B MICROS PRACTICA 4 Saucedo 5
Date: Sunday , April 15, 2018 Sheet 1 of 1
SW DIP-8
J2 J1
2 1 2 1
MCL 4 3 MCL RB7 4 3
6 5 RA0 RB6 6 5
8 7 RA1 RB5 8 7
10 9 RA2 RB4 10 9
12 11 RA3 RB3 12 11
14 13 RA4 RB2 14 13
CATODO COMUN
U3 RN3
16 15 RA5 RB1 16 15
RE0 18 17 RE0 RB0 18 17 7 13 1 14 a
RE1 RE1 VDD D0 A a
20 19 20 19 1 12 2 13 b
RE2 22 21 RE2 GND 22 21 GND 2 D1 B 11 3 12 c
VDD VDD RD7 D2 C f b
24 23 24 23 6 10 4 11 d
GND 26 25 GND RD6 26 25 D3 D 9 5 10 e
R3 R2 7448
RC0 28 27 RC0 RD5 28 27 3 E 15 6 9 f
220 220
RC1 RC1 RD4 LT F g
30 29 30 29 5 14 7 8 g
RC2 32 31 RC2 RC7 32 31 RC7 RBI G
RD0 34 RC6 RC6 e c
33 34 33 4
RD1 36 35 RD3 36 35 BI/RBO
Vusb Vusb RD2 220 DECENAS d
D3 D2
7 13 1 14 a a
1 D0 A 12 2 13 b
2 D1 B 11 3 12 c
D2 C f b
MILES 6 10 4 11 d
D3 D 9 5 10 e
7448 E
CATODO COMUN 3 15 6 9 f g
U4 RN4 5 LT F 14 7 8 g
RBI G
e c
7 13 1 14 a a 4
1 D0 A 12 2 13 b BI/RBO
D1 B 220 UNIDADES d
2 11 3 12 c f b
6 D2 C 10 4 11 d
D3 D 9 5 10 e
7448 E
3 15 6 9 f g
5 LT F 14 7 8 g
RBI G
e c
4
BI/RBO
220 CENTENAS d
;**************************************************************************
; 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: Puerto A = entrada Puerto B = Complemento a uno de PA *
; Date: 12/01/11 *
; File Version: 1.0 *
; *
; Author: Ing. Alejandro Vicente Lugo Silva / J. Luis Bravo L. *
; Company: Acad. Computación ICE - ESIME Zac.
*
; *
;**************************************************************************
;*************************************************************************
;
;**************************************************************************
;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
VAR EQU 0x00 ;define variable en localidad 0 de memoria de datos
cont_s EQU 0x01
cuenta equ 0x02
conteo equ 0x03
RES1 EQU 0x04
RES2 EQU 0x05
COC equ 0x06
BCDx equ 0x08
BCDy equ 0x09
MiDEN equ .10
NUME equ 0x0b
RMND_L equ 0x0e
rlf macro file,dest
rlcf file,dest
endm
rrf macro file,dest
rrcf file,dest
endm
rlnf macro file,dest
rlncf file,dest
endm
;*************************************************************************
;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.
SB equ 7
max_AD equ 0xAC
CARRY equ 0
bcdU equ 0x13
bcdH equ 0x14
binL equ 0x17
binH equ 0x16
bcdL equ 0x15
RESET_VECTOR ORG 0
;**************************************************************************
;Start of main program
; The main program code is placed here.
ORG 0x1000
Main:
CfgTMR0
;T1CON.T1CKPS1 = 1; // bits 5-4 Prescaler Rate Select bits
;T1CON.T1CKPS0 = 0; // bit 4
;T1CON.T1OSCEN = 1; // bit 3 Timer1 Oscillator Enable Control: bit 1=on
;T1CON.T1SYNC = 1; // bit 2 Timer1 External Clock Input Synchronization
Control bit: 1=Do not synchronize external clock input
;T1CON.TMR1CS = 0; // bit 1 Timer1 Clock Source Select bit: 0=Internal
clock (FOSC/4) / 1 = External clock from pin T13CKI (on the rising edge)
;T1CON.TMR1ON = 1; // bit 0 enables timer
;TMR1H = $5D; // preset for timer1 MSB register
;TMR1L = $3D; // preset for timer1 LSB register
movlw 0x87
movwf T0CON,1
movlw 0x24
movwf TMR0H,1
movlw 0x72
movwf TMR0L,1
bsf INTCON,GIE
bcf RCON,IPEN
bsf INTCON,TMR0IE
return
;**************************************************************************
; Cfgptos - Subrutina para configurar los puertos de E/S
Cfgptos
LinFeedSR:
; rlnf RANDOM,W
rlnf RANDOM,W
BTFSC RANDOM,4
XORLW 1
BTFSC RANDOM,5
XORLW 1
BTFSC RANDOM,2
XORLW 1
MOVWF RANDOM
RETLW 0
convBCDx movf cont_s,W
movwf NUME
movlw MiDEN
clrf COC,1 ; limpia cociente
D_1 incf COC,1 ; incrementa al cociente cada resta
subwf NUME,1 ; NUME - WREG -> WREG
bc D_1 ; si positivo, regresar
addwf NUME,1 ; si demasiados este es 1er digito
decf COC,1 ; si demasiados para el cociente
movff NUME,RMND_L ;salva 1er digito BCD (unidades)
movff COC,NUME ; repite mismo proceso
clrf COC,1 ; limpia cociente
D_2 incf COC,1
subwf NUME,F
bc D_2
addwf NUME,1
decf COC,1
movf NUME,W
swapf WREG
addwf RMND_L,W
movwf BCDx
movwf LATD
return
convBCDy return
; Delay = 1 seconds
; Clock frequency = 48 MHz
cblock
dd1
dd2
dd3
endc
Delay
;11999993x1.2 cycles
movlw 0xb5
movwf dd1
movlw 0x64
movwf dd2
movlw 0x20
movwf dd3
Delay_0
Decfsz dd1, f
Prof. S. Saucedo 6 mar/2018
Goto goto2
decfsz dd2, f
goto2 goto goto3
decfsz dd3, f
goto3 goto Delay_0
;http://www.electro-tech-online.com/threads/flashing-led-pk2error0029.42691/
;3 cycles
goto alnop
alnop nop
;4 cycles (including call)
return
;**************************************************************************
;End of program
END