At 10:44 AM 12/3/03 +0000, you wrote:
>I'm using the following code for software direct digital waveform synthesis:
Ah, it just showed up.
> 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?
OK, this makes things a little more clear.
Q: Is your distortion coming from loop to loop delay or from the delay
between set and clear? (I suspect the latter).
RobertMessage
Re: [lpc2100] Problem with DDS
2003-12-03 by Robert Adsett
Attachments
- No local attachments were found for this message.