Práctica 1:
Periféricos e Interfaces industriales
1 1
f = 12 MHz → T = =
f 12 MHz
1
1 ciclo máquina = 12T = = 1µs
1MHz
Calcula el valor del Contador para que el siguiente código genere un retardo de
1/8 s.
retardo:
DJNZ CONTADOR, retardo
Para realizar la “operación” DJNZ tarda 2µs, por tanto en 1/8 s tardará:
1
= 62.500 veces
8x2 µ
MOV CONTH,#ValorContH
buclealto:
MOV CONTL,#ValorContL
buclebajo:
DJNZ CONTL,buclebajo
DJNZ CONTH,buclealto
1
Periféricos e Interfaces Industriales
62.500
≈ 244
→ ValorContH = 244
256
BE (bucle externo)
Donde BI (bucle interno) = 2µs x ValorContL
74LS373 LEDs
330
P1
LE OE
2
Periféricos e Interfaces Industriales
Inicio
Cargar
acumulador
Cargar valor
acumulador
a P1
Retardo
Rotar derecha
Cargar valor
a P1
Retardo
SI NO
= 01H
Rotar izquierda
Cargar valor
a P1
Retardo
NO
= 80H
SI
3
Periféricos e Interfaces Industriales
.ORIGIN 0000H
JMP INI
.END
4
Periféricos e Interfaces Industriales
#include <io51.h>
5
Periféricos e Interfaces Industriales
for(;;)
{
rotar() ;
}
}
Inicio
Configuración
NA: JMP NA
Recarga valores
Mover leds
Izquierda Derecha
Dirección
SI NO
P1 = 80H SI NO
P1 = 01H
Rotar
Dirección izquierda
Dirección Rotar
derecha
6
Periféricos e Interfaces Industriales
RETI
.ORIGIN 0000H
JMP INI
IZQ: JB P1.7,CAM
MOV A,P1
RL A
MOV P1,A
JMP FIN
7
Periféricos e Interfaces Industriales
8
Periféricos e Interfaces Industriales
TH0 = 0x0B ;
TL0 = 0xDB ;
TR0 = 1 ;
for (;;) /* Bucle infinito. */
{
}
}