AnsweredAssumed Answered

Issue with Audio Output on the EZ-Kit 21262

Question asked by dramsay on Apr 19, 2011
Latest reply on Feb 25, 2016 by Krissy

Hey all,

 

I'm working on a project with the ADSP-21262 EZ-Kit lite, using the Block-based talk-thru (C) as a starting point.  I've left pretty much everything as default, except I took out the interrupt routine for changing the volume because I need the flag for SPI chip select in tandem with the talkthrough.

 

For starters, I'm trying to simply synthesize a sin wave out of one of the output channels.  I've altered processBlock.c as follows:

 

#include "tt.h"
#include <stdlib.h>
#include <math.h>
#include <iso646.h>

 

// Place the audio processing algorith here. The input and output are given
// as unsigned integer pointers.
double sin_lookup[2048]= {
                         #include "sin_func.dat"
                      };
  
int test_array[1024];                     
                                        
unsigned int my_sin(double Amplitude, long float freqHz);

 

void processBlock(unsigned int *block_ptr)
{
    int i;
    float temp_out;

 

    //Clear the Block Ready Semaphore
    blockReady = 0;
   
    //Set the Processing Active Semaphore before starting processing
    isProcessing = 1;

 

    for(i=0;i<NUM_SAMPLES;i+=2)
    {
    long float freq = (100*i)/48000.0;
    
     test_array[i]=my_sin(60000,freq);
    
     *(block_ptr+i) = test_array[i];  
     }

 


    //Clear the Processing Active Semaphore after processing is complete
    isProcessing = 0;
}

 


unsigned int my_sin(double Amplitude, long float freqHz)
{
    long float index = (freqHz * 2047.0);
   
    int ind1 = floor(index);
   
    if (ind1 > 2046)
        {   
        ind1 = fmod(index,2047);
        index = fmodf(index,2047.0);
        }
       
    long float sin_val = sin_lookup[ind1];
   
    sin_val = sin_val + ((index - ind1) * (sin_lookup[ind1+1] - sin_val));

 

    //Scale Amplitude between 0 and 8,388,607
    //enter code here
   
    sin_val = floor(sin_val*Amplitude);
   
    if (sin_val < 0)
            {
            sin_val = sin_val + 0x01000000;    
            }   
       
   
    return sin_val;       
}

 

 

(Where sin_func.dat is simply a 2048 point table lookup for one period of a sin wave). Now when I look at the values (which I've done using the plot window, looking at L and R channels by skipping every other point in the Block_A, Block_B, and Block_C), I'm getting inconsistent results.  Plotting the test array against the Block_A, B, and C shows that the Block_A samples are consistently 15 ahead of the test array, and the last 10 or so samples are all over the place (though all positive).  The test array is working exactly as I had hoped, so there is no problem with my sine code, but writing it to the block is failing.  When I attempt to just call the pointer without the test array (*(block_ptr+i) =my_sin(60000,freq); ) nothing appears to be getting through, and again the last 10 samples jump all over the place.

 

Listening back demonstrates that the write is actually occuring, as I can get each of the stereo channels to buzz at sort of the right frequency.  What is going on?  The pointer reference seems like it should be writing properly to the block- I thought maybe it was just a visual problem with where I was halting the program and the plot, but the audio confirms that a lot of noise is being introduced.  I'm quite puzzled as to why I can't write the data to the block properly, and I'm at a loss for what the issue could be.

 

Also, is there a way to plot two's compliment so it's viewable as intended? I haven't been able to find one, but I thought I'd check.

 

 

Thank you so much for any help, I sincerely appreciate it!

Outcomes