FUNCTION GENERATION

Function:     Generate random noise, sine wave, sawtooth wave or a sweeping sine wave
                     on the C54x DSKPlus.

Location:     ftp://ftp.ti.com/pub/tms320bbs/c5xxdskfiles/Func.exe
By:              William Erfurt


Function Generation Application Code: dskpfunc.exe

Starting off:
The file "dskpfunc.exe" can be downloaded from the above listed FTP site to provide generation of several different wave forms a on the C54x DSK Plus. First save dskpfunc.exe into it’s own directory. Then run the executable (either in DOS or Windows) allowing it to explode into the following list of files:

        dskpfunc.exe    - The original file that was downloaded
        Main,asm        - Main assembly program
        Main.lst        - List file
        Main.obj        - Object file for main assembly program
        Ac01init.asm    - Initializes the analog interface on the DSK Plus
        Vectors.asm     - Initializes the C542 interrupt vector table
        readme.txt      - Read me file

Using the debugger download and run the file main.obj. With this program you can generate various functions with the C54xDSK. After you load the program you must specify what function you would like to generate. To do this use the debugger interface to modify register AR3 (it is defaulted to FFFF when the program is loaded) . Modify AR3 to 1, 2, 3, 4 for the following waveforms:

You can connect a speaker or an oscilloscope to the output RCA jack to observe the output. The jacks are labeled on the DSK board, for more information on the jacks please see the TMS320C54x DSKPlus User’s Guide page 1-4.

For information on how to modify the code to generate different frequency waves please see the "HINTS" section on the next page.

Theory:

SINE WAVE:

The following difference equation is used to generate the sine wave:

y[n]=Ay(n-1)+By(n-2)

SAWTOOTH WAVE:

To generate the sawtooth wave accumulator A is continuously incremented by 80 (50 hex). The digital value of the lowest 16 bits of the A accumulator is used as the output and converted to an analog waveform. The value of accumulator A continues to grow until it overflows. When the overflow occurs the a new period of the sawtooth wave begins.

A = A + 80

This operation occurs each time the AC01 interrupts, generating a new output.

SWEEPING SINE WAVE:

The sweeping sine wave is based on the same difference equation that the sine wave generator is based on, however the coefficient A (labeled Ncoeff) is variable. Ncoeff is incremented to a max value and then dectemented to a min value which results in the wave growing in frequency and amplitude and then shrinking again.

Hints:
To change the frequency of the sine wave:
look to the line:

        
File: "main.asm"
        Under "VARIABLE AND GOLBAL FUNCTION DECLARATIONS"
        try changing the value of  "coeff" the default value is 078d
        
        coeff   .word   078dh

Observe the changes that you have made on an oscilloscope or with a speaker.

To change the frequency of the sawtooth wave: look to the line:

        
File: "main.asm"
        Under the sawtooth code section, change the value that is used 
        to incremented the A accumulator. The default value is "10" (when 
        left shifted 10 it equals 80 or 50 hex) Increasing/decreasing it 
        increases/decreases  the frequency sawtooth frequency. 

        Sawtooth
                A = A + #10 << 3

Observe the changes that you have made on an oscilloscope or with a speaker.

To change the sampling frequency, look to the line:

        
File: "Ac01init.asm"
        REG1    .set    124h
        reg2    .set    20fh

The sampling frequency is defined by:
        Sampling Frequency = MCLK/ ( 2 * A * B)
where:
        MCLK = 10Mhz
        A    = Bits 0 to 8 of REG1 (for example: REG1 = 124, then A = 24)
        B    = Bits 0 to 8 of REG2 (for example: REG2 = 20f, then  B= 0f)


Refer to page 2-20 in the "TLC320AC01C User’s Manual" for more information.