Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2100] Problem with DDS

2003-12-03 by Robert Adsett

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, III

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.