TODOPIC
Bienvenido(a),
Visitante
. Por favor,
ingresa
o
regístrate
. ¿Perdiste tu
email de activación
?
1 Hora
1 Día
1 Semana
1 Mes
Siempre
Ingresar con nombre de usuario, contraseña y duración de la sesión
Este tema
Este sub-foro
Todo el foro
Google
Inicio
Ayuda
Buscar
Ingresar
Registrarse
TODOPIC
»
Microcontroladores PIC
»
Almacén del Assembler
(Moderadores:
MGLSOFT
,
PAOLA09
,
Suky
) »
Frecuencimetro
« anterior
próximo »
Imprimir
Páginas:
1
[
2
]
Ir Abajo
Autor
Tema: Frecuencimetro (Leído 9540 veces)
0 Usuarios y 1 Visitante están viendo este tema.
jhordyb3xd
PIC10
Mensajes: 7
Re:Frecuencimetro
«
Respuesta #15 en:
20 de Noviembre de 2019, 19:23:07 »
Lo que yo no entiendo bien es como implementar la rutina de conversión, y qué valores debo tomar de ahí para pasarás a centenas, decenas y unidades
En línea
Picuino
Moderadores
DsPIC33
Mensajes: 5892
Re:Frecuencimetro
«
Respuesta #16 en:
21 de Noviembre de 2019, 11:15:17 »
Prueba con esta:
http://www.piclist.com/techref/microchip/math/radix/b2bu-24b9d-xx.htm
Código: ASM
BIN2DEC
:
clrf DEC0
; Clear decimal output buffer
clrf DEC1
clrf DEC2
clrf DEC3
clrf DEC4
clrf DEC5
clrf DEC6
clrf DEC7
; NB. BINn and FSR are trashed after this routine
movlw
24
; Initiate bit loop
movwf BIT_COUNTER
BITLOOP
:
rlf BIN0
,
F
; Every iteration of this loop will copy the next
rlf BIN1
,
F
; bit of the bin value, starting with the MSB,
rlf BIN2
,
F
; to the carry flag
movlw DEC0
movwf FSR
; Initiate DECn pointer and counter
movlw
8
movwf DEC_COUNTER
; The following is executed 8 times per bit
DECLOOP
:
rlf INDF
,
F
; Multiply DECn by two with carry, DECn * 2 + C
movlw
-
10
; See note above - test for DECn > 9
addwf INDF
,
W
; W = DECn -10, if W = positive or zero, C = 1
btfsc STATUS
,
C
; DECn has overflowed (>>9) if carry is set
movwf INDF
; If carry is set DECn = DECn - 10
incf FSR
,
F
; Carry is CARRIED over to next multiply
decfsz DEC_COUNTER
,
F
goto DECLOOP
; Multiply next DECn
decfsz BIT_COUNTER
,
F
goto BITLOOP
; Do next bit
retlw
0
; Could be RETURN on most PICs
Es para 24 bits, mucho más de lo que necesitas, pero creo que te funcionará bien.
Tienes que declarar las variables.
En BIN0 ... BIN3 metes el número binario.
En DEC0 ... DEC7 obtienes el número en 8 cifras bcd
Además necesitas declarar dos contadores.
Un saludo.
«
Última modificación: 21 de Noviembre de 2019, 11:26:13 por Picuino
»
En línea
Picuino
Moderadores
DsPIC33
Mensajes: 5892
Re:Frecuencimetro
«
Respuesta #17 en:
21 de Noviembre de 2019, 11:19:14 »
Esta es la modificación para que la rutina convierta solo 10 bits binarios sobre 4 bytes BCD.
No está probado, así que puede tener errores:
Código: ASM
BIN2DEC
:
clrf DEC0
; Clear decimal output buffer
clrf DEC1
clrf DEC2
clrf DEC3
movlw
10
; Initiate bit loop
movwf BIT_COUNTER
BITLOOP
:
rlf BIN0
,
F
; Every iteration of this loop will copy the next
rlf BIN1
,
F
; bit of the bin value, starting with the MSB, to the carry flag
movlw DEC0
movwf FSR
; Initiate DECn pointer and counter
movlw
4
movwf DEC_COUNTER
; The following is executed 4 times per bit
DECLOOP
:
rlf INDF
,
F
; Multiply DECn by two with carry, DECn * 2 + C
movlw
-
10
; See note above - test for DECn > 9
addwf INDF
,
W
; W = DECn -10, if W = positive or zero, C = 1
btfsc STATUS
,
C
; DECn has overflowed (>>9) if carry is set
movwf INDF
; If carry is set DECn = DECn - 10
incf FSR
,
F
; Carry is CARRIED over to next multiply
decfsz DEC_COUNTER
,
F
goto DECLOOP
; Multiply next DECn
decfsz BIT_COUNTER
,
F
goto BITLOOP
; Do next bit
retlw
0
; Could be RETURN on most PICs
Un saludo.
«
Última modificación: 21 de Noviembre de 2019, 11:23:20 por Picuino
»
En línea
Picuino
Moderadores
DsPIC33
Mensajes: 5892
Re:Frecuencimetro
«
Respuesta #18 en:
28 de Noviembre de 2019, 19:05:41 »
¿Ha funcionado?
En línea
jhordyb3xd
PIC10
Mensajes: 7
Re:Frecuencimetro
«
Respuesta #19 en:
02 de Diciembre de 2019, 17:14:44 »
Si funcionó bien con el segundo, porque los que me pasaban antes no funcionaba, pero estos si
En línea
Imprimir
Páginas:
1
[
2
]
Ir Arriba
« anterior
próximo »
TODOPIC
»
Microcontroladores PIC
»
Almacén del Assembler
(Moderadores:
MGLSOFT
,
PAOLA09
,
Suky
) »
Frecuencimetro
anything