--- In lpc2100@yahoogroups.com, Ben Dooks <ben@f...> 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.
>
> what is the compiler outputing for this code? do you have a disassembly
> of the code being produced?
>
Thanks for the suggestion.
This is what I'm getting:
while (1)
40000150 E3A0024E mov r0, #0xe0000004
40000154 E280090A add r0, r0, #0x28000
40000158 E59F1028 ldr r1, [pc, #40]
4000015C E3A022CE mov r2, #0xe000000c
40000160 E282290A add r2, r2, #0x28000
{
acc = acc + adder; //update phase accumulator
40000164 E084400C add r4, r4, r12
ptr = (acc &= 0xFF); //pointer into table
40000168 E20440FF and r4, r4, #0xff
IOSET = square[ptr] << 8;//output byte to port
4000016C E7D43001 ldrb r3, [r4, r1]
40000170 E1A03403 mov r3, r3, lsl #0x8
40000174 E5803000 str r3, [r0, #0]
IOCLR = ~(square[ptr] << 8);
40000178 E7D43001 ldrb r3, [r4, r1]
4000017C E1E03403 mvn r3, r3, lsl #0x8
40000180 E5823000 str r3, [r2, #0]
40000184 EAFFFFF6 b -10 ; 0x40000164
40000188 4000062C andmi r0, r0, r12, lsr #0xc
}
I'm not all that familiar with ARM assembler, but it looks about
right. I'm using the Rowley tools, which use the GNU compiler.
LeonMessage
Re: Problem with DDS
2003-12-03 by leon_heller
Attachments
- No local attachments were found for this message.