Hi Leon -
I don't step deep into it but as you using variables greater 8 bits what's
about little-endian/big-endian confusion, maybe?
Regards -
Henry
-----Urspr\ufffdngliche Nachricht-----
Von: Leon Heller <leon_heller@...>
An: lpc2100@yahoogroups.com <lpc2100@yahoogroups.com>
Datum: Mittwoch, 3. Dezember 2003 11:46
Betreff: [lpc2100] Problem with DDS
>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_heller
>
>
>To unsubscribe from this group, send an email to:
>lpc2100-unsubscribe@yahoogroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>Message
Re: [lpc2100] Problem with DDS
2003-12-03 by otc_friend
Attachments
- No local attachments were found for this message.