AnsweredAssumed Answered

How to View Variable Values?

Question asked by SneakyPanda on Mar 17, 2017
Latest reply on Mar 29, 2017 by SneakyPanda

Hello there,

 

I'm new to CCES and I can't figure out how to check the value of the variables contained in my code. In Matlab, there is a workspace that shows all of the variables and you can click on them to see their contents. CCES seems to have a similar window called "outline" and I can see all of the variable names contained in the code but I cannot check their values. I've also used the "variable" view whilst debugging but it also does not show the value of any variables. I've tried setting breakpoints near or around the variable to no avail. The variable I am trying to see is called hlp, which is an array of low pass filter coefficients. Here is the code.

 

/*****************************************************************************
 * Parametric Audio Equalizer.c
 *****************************************************************************/
#define pi 3.14159265358979323846
#define codec_in  ((volatile long fract *)0x2004D0C4)
#define codec_out ((volatile long fract *)0x2004D040)
#include <sys/platform.h>
#include "adi_initialize.h"
#include "Parametric Audio Equalizer.h"
#include "filter.h"
#include "math.h"
#include "matrix.h"
#include "float.h"
#include "stdio.h"
#include <cdefBF706.h>
#include "stdfix.h"

 

float fs = 48000;             //Sampling Frequency
float N = 101;                //Length of impulse response
float M = 1024;               //FFT Length
float fc = 100;               //Bandpass filter center frequency (Hz)
float wc = 0;                    //Bandpass filter center frequency (radians)
float d = 0;                  //Sinc function symmetry point offset
long fract n[101] = {0};
float flp;                       //Low pass filter corner frequency (Hz)
float flp = 600;              //Low pass filter corner frequency (Hz)
float wlp = 0;             //Low pass filter corner frequency in (radians)
long fract hlp[101];    //Array of Band-pass Filter Impulse Response Coefficients
long fract hbp[101];      //Array of Low-pass Filter Impulse Response Coefficients

 

void TWI_write(uint16_t, uint8_t);
    void codec_configure(void);
    void sport_configure(void);
    // Function sport_configure initialises the SPORT0. Refer to pages 26-59, 26-67,
    // 26-75 and 26-76 of the ADSP-BF70x Blackfin+ Processor Hardware Reference manual.
    void sport_configure()
    {
      *pREG_PORTC_FER=0x0003F0;             // Set up Port C in peripheral mode
      *pREG_PORTC_FER_SET=0x0003F0;         // Set up Port C in peripheral mode
      *pREG_SPORT0_CTL_A=0x2001973;         // Set up SPORT0 (A) as TX to codec, 24 bits
      *pREG_SPORT0_DIV_A=0x400001;          // 64 bits per frame, clock divisor of 1
      *pREG_SPORT0_CTL_B=0x0001973;         // Set up SPORT0 (B) as RX from codec, 24 bits
      *pREG_SPORT0_DIV_B=0x400001;          // 64 bits per frame, clock divisor of 1
    }
    // Function TWI_write is a simple driver for the TWI. Refer to page 24-15 onwards
    // of the ADSP-BF70x Blackfin+ Processor Hardware Reference manual.
    void TWI_write(uint16_t reg_add, uint8_t reg_data)
    {
      int n;
      reg_add=(reg_add<<8)|(reg_add>>8);    // Reverse low order and high order bytes
      *pREG_TWI0_CLKDIV=0x3232;             // Set duty cycle
      *pREG_TWI0_CTL=0x8c;                  // Set prescale and enable TWI
      *pREG_TWI0_MSTRADDR=0x38;             // Address of codec
      *pREG_TWI0_TXDATA16=reg_add;          // Address of register to set, LSB then MSB
      *pREG_TWI0_MSTRCTL=0xc1;              // Command to send three bytes and enable transmit

 

      for(n=0;n<8000;n++){}                 // Delay since codec must respond
      *pREG_TWI0_TXDATA8=reg_data;          // Data to write
      for(n=0;n<10000;n++){}                // Delay
      *pREG_TWI0_ISTAT=0x050;               // Clear TXERV interrupt
      for(n=0;n<10000;n++){}                // Delay
      *pREG_TWI0_ISTAT=0x010;               // Clear MCOMP interrupt
    }
    // Function codec_configure initialises the ADAU1761 codec. Refer to the control register
    // descriptions, page 51 onwards of the ADAU1761 data sheet.
    void codec_configure()
    {
      TWI_write(0x4000, 0x01);              // Enable master clock, disable PLL
      TWI_write(0x40F9, 0x7f);              // Enable all clocks
      TWI_write(0x40Fa, 0x03);              // Enable all clocks
      TWI_write(0x4015, 0x01);              // Set serial port master mode
      TWI_write(0x4019, 0x13);              // Set ADC to on, both channels
      TWI_write(0x401c, 0x21);              // Enable left channel mixer
      TWI_write(0x401e, 0x41);              // Enable right channel mixer
      TWI_write(0x4029, 0x03);              // Turn on power, both channels
      TWI_write(0x402A, 0x03);              // Set both DACs on
      TWI_write(0x40f2, 0x01);              // DAC gets L, R input from serial port
      TWI_write(0x40f3, 0x01);              // ADC sends L, R input to serial port
      TWI_write(0x400a, 0x0b);              // Set left line-in gain to 0 dB
      TWI_write(0x400c, 0x0b);              // Set right line-in gain to 0 dB
      TWI_write(0x4023, 0xe7);                // Set left headphone volume to 0 dB
      TWI_write(0x4024, 0xe7);              // Set right headphone volume to 0 dB
      TWI_write(0x4017, 0x00);              // Set codec default sample rate, 48 kHz
    }

 

#pragma optimize_for_speed
int main(void)
{
    int i = 0;
    /**
     * Initialize managed drivers and/or services that have been added to
     * the project.
     * @return zero on success
     */
    adi_initComponents();
    
    /* Begin adding your custom code here */

 

    for ( i = 0; i < 101; i++ ) {
          n[i] = i; // set element at location i*
       }

 

    wc = 2*pi*fc/fs;  //Bandpass filter center frequency (radians)
    d = (N-1)/2;      //Sinc function symmetry point offset
    wlp = 2*pi*flp/fs;   //Low pass filter corner frequency in (radians)

 

    // Low Pass Filter
    for (i = 0; i < 101; i++) {
    hlp[i] = (wlp/pi)*sin(((wlp/pi)*(n[i]-d))/((wlp/pi)*(n[i]-d)));
    }
    /*
    for (i = 0; i < 101; i++) {
    // Bandpass Filter Translated from Windowed Low Pass Filter
    hbp[i] = 2*hlp*cos(wc*(n[i]-d));
    }*/

 

    int m, n, modtype;
      bool my_audio=true;
      long fract x[2000]={0}, y;
      modtype=101;                                       // There are 255 coefficients
      n=0;
      m=0;
      codec_configure();                                 // COnfigure the codec
      sport_configure();                                 // Configure SPORT0
      while(my_audio)
      {
        while((*pREG_SPORT0_CTL_B & 0xc0000000)==0x0){}  // Wait for input buffer flag, left
        y=0;
        x[n]=*codec_in;                                  // Read new word, left
        for (m=0;m<(modtype);m++)
        {
          if(n>=modtype) n=0;                            // Modulus addressing
          //y+=hlp[m];                                     // Allow the input to pass through without filtering
          y+=hlp[m]*x[n];                                  // Convolve
          n++;
        }
        n--; if(n<0) n=(modtype);                        // Rotate buffer
        *codec_out=y;                                    // Send out left ch, filtered
        while((*pREG_SPORT0_CTL_B & 0xc0000000)==0x0){}  // Wait for input buffer flag, right
        *codec_out=*codec_in;                            // Read right channel in, send out
        while((*pREG_SPORT0_CTL_B & 0xc0000000)==0x0){}  // Wait for input buffer flag, left
           *codec_out=*codec_in;                            // Read right channel in, send out
      }
      return 0;
    }

Outcomes