Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Carlos Canto Q.
MICROCONTROLADORES
Nibble alto
Nibble alto
Nibble bajo
Nibble bajo
Carlos Canto Q.
MICROCONTROLADORES
Rutina generadora de retardos (ESPERA)
R2 N0
R2 N0
R2=0
?
R2=0
?
Ret
Ret
R3 R3-1
R3 R3-1
R2 R2-1
R2 R2-1
R3=0
?
R3=0
?
ESPERA
ESPERA
PROGRAMA FUENTE
MOV R3,#N1
LCALL ESPERA
.
.
.
.
;Subrutina ESPERA
ESPERA_40:
DELAY: MOV R2,#N0
AQU: DJNZ R2,AQU
DJNZ R3,DELAY
RET
NO
NO
SI
SI
Antes de invocar a esta subrutina se debe
cargar R3 con el correspondiente N1
Antes de invocar a esta subrutina se debe Antes de invocar a esta subrutina se debe
cargar R3 con el correspondiente N1 cargar R3 con el correspondiente N1
Carlos Canto Q.
MICROCONTROLADORES
CLCULO DEL RETARDO GENERADO POR LA RUTINA DELAY (>=40s) C C LCULO DEL RETARDO GENERADO POR LA RUTINA DELAY (>=40 LCULO DEL RETARDO GENERADO POR LA RUTINA DELAY (>=40 s) s)
2s R3 R3 24 DJNZ R3,DELAY
2S 1 24 RET
2s(R2xR3) R2xR3 24 DJNZ R2,AQUI AQU:
1S ( R3 ) R3 12 MOV R3,#N0 DELAY:
t ttotal total
# de ejecuciones # de ejecuciones # de T # de T Mnem Mnem nico nico Etiqueta Etiqueta
Si suponemos que ; fosc=12 Mhz T=(1/12)s
t tTOT TOT= [1R3+ = [1R3+2R2xR3 2R2xR3+2R3 +2] +2R3 +2] s s =[ =[2R2xR3 2R2xR3+3R3+2] +3R3+2] s s
R3(2R2+3) = R3(2R2+3) = t tTOT TOT- -2 ; 2R2+3=( 2 ; 2R2+3=(t tTot Tot- -2)/ 2)/R3 R3 R2 R2 = [( = [(t tTOT TOT- -2)/2R3] 2)/2R3]- -3/2 ; 3/2 ;
si si R3=1 R3=1 para para t tTOT TOT=50 =50 s s entonces calculamos entonces calculamos
N0=[(50 N0=[(50- -2)/2] 2)/2]- -1.5=22.5~23 tenemos que para conseguir un retardo 1.5=22.5~23 tenemos que para conseguir un retardo
> de 40 > de 40 s s R2=23 R2=23
Carlos Canto Q.
MICROCONTROLADORES
CLCULO PARA OBTENER EL RETARDO >= 4.1 mS C C LCULO PARA OBTENER EL RETARDO >= 4.1 LCULO PARA OBTENER EL RETARDO >= 4.1 mS mS
R2=[( R2=[(t tTOT TOT - -2)/2R3] 2)/2R3]- -3/2 ; ya que R2=23 3/2 ; ya que R2=23 para para t tTOT TOT=50 =50 s s
Despejando R3, tenemos que: Despejando R3, tenemos que:
R3=( R3=(t tTOT TOT- -2)/(2R2+3) ;sustituimos 2)/(2R2+3) ;sustituimos t tTOT TOT= 4.5 = 4.5 ms ms= 4500 = 4500 s s
y R2=23 y R2=23
Tenemos que: R3= 4498/[2(23)+3]=4498/49=91.8 ~92 Tenemos que: R3= 4498/[2(23)+3]=4498/49=91.8 ~92
Finalmente con: Finalmente con:
R2=23 R2=23 y y R3=92 R3=92 obtenemos un retardo > de 4.1 obtenemos un retardo > de 4.1 ms ms
Carlos Canto Q.
MICROCONTROLADORES
CLCULO PARA OBTENER EL RETARDO >= 100S C C LCULO PARA OBTENER EL RETARDO >= 100 LCULO PARA OBTENER EL RETARDO >= 100 S S
R3=( R3=(t tTOT TOT- -2)/(2R2+3) ;sustituimos 2)/(2R2+3) ;sustituimos t tTOT TOT=100 =100 s s
Tenemos que: R3= 98/49 =2 Tenemos que: R3= 98/49 =2
Finalmente con: Finalmente con:
R2=23 R2=23 y y R3=2 R3=2 obtenemos un retardo > de 100 obtenemos un retardo > de 100 s s
Carlos Canto Q.
MICROCONTROLADORES
CLCULO PARA OBTENER EL RETARDO >= 1.64mS C C LCULO PARA OBTENER EL RETARDO >= 1.64mS LCULO PARA OBTENER EL RETARDO >= 1.64mS
R3=( R3=(t tTOT TOT- -2)/(2R2+3) ;sustituimos 2)/(2R2+3) ;sustituimos t tTOT TOT=1,640 =1,640 s s
Tenemos que: R3=1638/49 =33.43~34 Tenemos que: R3=1638/49 =33.43~34
Finalmente con: Finalmente con:
R2=23 R2=23 y y R3=34 R3=34 obtenemos un retardo > de 1.64 obtenemos un retardo > de 1.64 m ms s
Carlos Canto Q.
MICROCONTROLADORES
CLCULO PARA OBTENER EL RETARDO >= 15 mS C C LCULO PARA OBTENER EL RETARDO >= 15 LCULO PARA OBTENER EL RETARDO >= 15 mS mS
Si cargamos R3 con 180 Si cargamos R3 con 180
Tenemos que : Tenemos que :
t tTOT TOT=[R3(2R2+3)+2] =[R3(2R2+3)+2] s s= 180(49) +2=8822 = 180(49) +2=8822 s s
t tTOT TOT=8.822ms =8.822ms
Por lo tanto si invocamos 2 veces esta subrutina Por lo tanto si invocamos 2 veces esta subrutina
obtenemos un retardo de obtenemos un retardo de 17.644 17.644 ms ms > 15ms > 15ms