Hz converter to Frqa in Asembler for beginners
hal2000
Posts: 66
HZ converter to Frqa in Asembler
Hi, I think that this routine can be useful.
You may already published another user's·
In routines where you have to be doing many frequency adjustments
is slow spin, that is why I translated it to Assembler
Forgive my bad English ;-)
The code has commentary in Spanish.
It is code to be added to your routine in Assembler
Greetings to all
Code Assembler:
DAT
'Ejemplo de uso
' mov hz,y·············· 'HZ envia
' call #Com_fre········ 'llama a la rutina
' mov frqa,F_os······· 'F_os tiene el valor para el oscilador
'
'==========================================================================
'Covierte HZ en NCO el regitro de entrada es Hz y el d salida F_os
'==========================================================================
Com_fre··········· mov···F_os,#0
······················ shl···· Hz,#1
······················ mov·· rep32,#32
Fre_loop··········· shl···· F_os,#1
······················ cmps· CLKFRE,Hz wc,wz
········· if_c_or_z subs· Hz,CLKFRE
········· if_c_or_z adds· F_os,#1
························ shl·· Hz,#1
······················ djnz·· rep32,#Fre_loop
Com_fre_ret ret
CLKFRE long 80_000_000
HZ res 1······························· 'variables conversor de frecuencia al oscilador
F_os res 1
rep32 res 1
Code SPIN
PRI HzToNCO(a) : f
a <<= 1
repeat 32 'perform long division of a/clkfreq
f <<= 1
if a => CLKFREQ
a -= CLKFREQ
f++
a <<= 1
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Did the curiosity kill the cat?
......................................
Envio editado por (hal2000) : 9/26/2009 2:28:26 PM GMT
Hi, I think that this routine can be useful.
You may already published another user's·
In routines where you have to be doing many frequency adjustments
is slow spin, that is why I translated it to Assembler
Forgive my bad English ;-)
The code has commentary in Spanish.
It is code to be added to your routine in Assembler
Greetings to all
Code Assembler:
DAT
'Ejemplo de uso
' mov hz,y·············· 'HZ envia
' call #Com_fre········ 'llama a la rutina
' mov frqa,F_os······· 'F_os tiene el valor para el oscilador
'
'==========================================================================
'Covierte HZ en NCO el regitro de entrada es Hz y el d salida F_os
'==========================================================================
Com_fre··········· mov···F_os,#0
······················ shl···· Hz,#1
······················ mov·· rep32,#32
Fre_loop··········· shl···· F_os,#1
······················ cmps· CLKFRE,Hz wc,wz
········· if_c_or_z subs· Hz,CLKFRE
········· if_c_or_z adds· F_os,#1
························ shl·· Hz,#1
······················ djnz·· rep32,#Fre_loop
Com_fre_ret ret
CLKFRE long 80_000_000
HZ res 1······························· 'variables conversor de frecuencia al oscilador
F_os res 1
rep32 res 1
Code SPIN
PRI HzToNCO(a) : f
a <<= 1
repeat 32 'perform long division of a/clkfreq
f <<= 1
if a => CLKFREQ
a -= CLKFREQ
f++
a <<= 1
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Did the curiosity kill the cat?
......................................
Envio editado por (hal2000) : 9/26/2009 2:28:26 PM GMT