DSPRelated.com
Forums

generating frequencies, no look-up need

Started by dspabout March 11, 2008
Hello, Im new to DSP. Does anybody have any example of numeric
oscillator in ASM for motorola 56K or 56Fxxx? Im looking to generate
several fixed frequencies no look-up table, just plain square output on
PIO. Thanks a lot
Hi,
Generating multiple precise frequencies is very easy.
You need a reference sampling frequency Fs much higher than the highest
frequency to generate.
Your algorithm must be called at each period of Fs (mostly into the
Timer Interrupt Service Routine)
Method:
generate sawtooth signals by adding an increment to a fractional
variable at each sampling period and letting it overflow from +1 to -1
The signs of sawtooth variables are then shifted out and applied to
your parallel port.
JM Ory

Fs equ 1E5 ; suppose Fs is 100kHz (generated by timer)
F0 equ 1234.0 ; definition of frequencies (floating point values)
... ; etc ...
Fn equ 9876.0 ;
N equ 16 ; number of frequencies
; Constant data:
org x:
delta_values
delta0 dc 2.*F0/Fs ;
... ;
delta_n dc 2.*Fn/Fs ; (Fractional values)

; Variable data
org x:
integs ds N ; Integrators (could be double for
more precision)

; Code called from the Interrupt Routine
org p:
...
Timer_Isr:
< Reset Timer Flag >
< save A, B, X0, Y0, Y1, R0, R1 if necessary >
clr b ; B = 0, Carry=0
move #0,y0 ; LSB = 0 if single precision
move #delta0,r0 ; R0 points begin of Constants table
move #integs,r1 ; R1 points begin of integrators
do #N,p1 ; Repeat N times ...
move x:(r0)+,y1 ; get one increment value in Y (or move
L:(r0)+,Y if double precision)
move x:(r1),a ; A <-- integrator values
adc y,a ; Long addition
move a1,x:(r1)+ ; A --> integrators (should be a10 in double
precision)
lsl a ; get sign of each integrator into Carry
rol b ; Save the carry bit into B1
p1 ; end repeat
move b,x:port ; write B into parallel port
< Restore all registers >
rti

dspabout a rit :

> Hello, Im new to DSP. Does anybody have any example of numeric
> oscillator in ASM for motorola 56K or 56Fxxx? Im looking to generate
> several fixed frequencies no look-up table, just plain square output on
> PIO. Thanks a lot
>
>