Code for dual channel DDS... - diyAudio
Go Back   Home > Forums > Blogs > googlyone

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Rate this Entry

Code for dual channel DDS...

Posted 25th January 2014 at 01:37 PM by googlyone
Updated 26th January 2014 at 05:34 AM by googlyone (Incomplete)

I was asked if I would share the code for the audio DDS I was playing with.

It is here...

Ver0.1.zip

I think this is all the files you need.

To show just how lazy I am, the main function is the file titled "dig_cross.c" - as that was the main function I edited as the base of this code. There is also a file "ad1940.c" which contains a bunch of the SPI stuff. This is yet another illustration of my bone idle-ness - as this module is probably a decade old. It is used, but has nothing to do with an AD1940 IC....

No apologies

There is a bunch of comments in this, but some general overview comments are:
- About 95% of the source code is about:
- Running the user interface
- Generating the display (rather utilitarian implementation)
- Reading from the EEPROM, and doing limit checks on data
- Writing to EEPROM

- There is a header file with an "outline" sinewave in it. This is only 4096 samples. The error correction occurs in the DDS section where the "remainder" of the DDS phase counter is used to linearly extrapolate the waveform. This pulls the spurs down an awful lot...

- Other waveform types are calculated in the user interface and loaded into a lookup table.

- And maybe 5% of the code is about running the DDS.

All of the DDS code is in the Interrupt Service Routine that is triggered by the I2S "half Empty" flag.

The DDS variables are calculated by the code in the main user interface routine.

The main ISR runs in about 75% of the "spare time" when the sample rate is set to 64KHz. Yes, that is an odd sample rate, but it allows the PIC to generate a very stable sample rate with "no - well no intentional" jitter. FYI: When you set a PIC up to generate an arbitrary sample rate, it does this by jittering the sample rate. Selecting an integer multiple of the master clock means the "intentional jitter" is disabled.

Things to note:
- This assumes it is running on one of the PIC32 boards I did. There is nothing fancy about these at all, and I am positive that pretty much any PIC32MX with Audio output and a decent amount of RAM would work fine.
- This assumes it is driving a DAC, but does not actually read from the DAC, it simply pumpss out I2S audio data. It does assume the DAC can handle 24bit data.
- I think the PIC documentation is a bit short of "decent". I would go as far as saying that I find it frustrating and confusing. There are a zillion libraries and zillion sets of manuals, many of them at cross purposes with one another. For a software dullard like me, it would be great of Microchip would publish a ful set in a simple suite, and not force you to go trawling through a quagmire of libraries and documentation.

- Oh, I meant to implement a function that would read a waveform from a USB stick, making this a true arbitrary waveform DDS. I havent got around to that.... I think I overlayed that with "noise" instead. but you will probably find bits of the user interface referring to "load from file". (I think)

Any questions, shoot me an email.

Phil
Posted in Uncategorized
Views 298 Comments 0 Email Blog Entry
Total Comments 0

Comments

 
Hide this!Advertise here!

New To Site? Need Help?

All times are GMT. The time now is 08:22 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2