I'm using the following code for software direct digital waveform synthesis:
int main(void)
{
unsigned int i;
unsigned long int acc, adder;
unsigned int ptr, temp;
initPLL();
MAMCR = 0;
MAMTIM = 5;
MAMCR = 2;
VPBDIV = 0x01;
portInit();
//main loop
//add value to accumulator
//load byte from current table
//output byte to port
//repeat
adder = 2000; //set up adder
acc = 0; //clear accumulator
while (1)
{
acc = acc + adder; //update phase accumulator
ptr = (acc &= 0xFF); //pointer into table
IOSET = square[ptr] << 8;//output byte to port
IOCLR = ~(square[ptr] << 8);
}
return 0;
}
but I can't get an equal mark-space ratio out of it for a square wave, and
sine waves are completely screwed up.
The following code for an AVR works very well:
; main loop
;
; r28,r29,r30 is the phase accumulator
; r24,r25,r26 is the adder value determining frequency
;
; add value to accumulator
; load byte from current table in ROM
; output byte to port
; repeat
;
LOOP1:
add r28,r24 ; 1
adc r29,r25 ; 1
adc r30,r26 ; 1
lpm ; 3
out PORTB,r0 ; 1
rjmp LOOP1 ; 2 => 9 cycles
I'm using the same AD557 8-bit DAC and the same look-up tables. I'm
obviously doing something silly, but I can't see what it is. Can anyone
help?
Leon
--
Leon Heller, G1HSM
Email: aqzf13@...
http://www.geocities.com/leon_hellerMessage
Problem with DDS
2003-12-03 by Leon Heller
Attachments
- No local attachments were found for this message.