At 11:23 AM 12/3/03 +0000, you wrote:
>On Wed, Dec 03, 2003 at 10:44:28AM -0000, Leon Heller wrote:
> > 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.
Strangely enough your original message doesn't seem to have propagated Leon.
There are definitely issues with how fast you can update the output ports
though. Given there is no delay in your loop that is likely to be having
an effect. If you insert a delay I expect that will square things up (of
course you'll get a slower wave :()
Robert
" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "
Kelvin Throop, IIIMessage
Re: [lpc2100] Problem with DDS
2003-12-03 by Robert Adsett
Attachments
- No local attachments were found for this message.