Quantcast
Channel: Processors
Viewing all articles
Browse latest Browse all 123898

Forum Post: problems with logical operators on C6713b

$
0
0

Hi,

I'm using the C6713 DSK from Spectrum Digital and I'm having some problems with logical operators in my code.

I am receiving input from the LINE IN jack, being commanded by my PC's audio output port. I am filtering (time domain, FIR) the audio signal on the DSP. The results of filtering appear fine because I send the results via the DSK's HEADPHONE jack back to my PC's mic port and I plot the results on my PC. I can see the FIR filter works properly.

I have some logic in the DSP code that should turn on the LED, signifying an amplitude achieved by the filtered result. Simply testing that the amplitude after filtering is above a threshold seems to correctly turn the LED on (and off). I do not want to see the LED flicker rapidly (I filter during each sample, and the rate is 8000 Hz), so I need to implement some logic that will hold the LED on for X samples. To do this, I have a nested-if structure. My problem is that the if-test on my boolean seems to do the opposite of what I need.

interrupt void c_int11()
{
  filteredResult = filter( getInput() );

  if( b_trigger > 0 ) // boolean is ON already
  {
    DSK6713_LED_on(1); // turn ON LED #1

    if( trigger_counter < X )
    {
      trigger_counter = trigger_counter + 1;
    }
    else
    {
      b_trigger = 0; // turn OFF boolean
    }
  }
  else // boolean is OFF
  {
    DSK6713_LED_off(1); // turn OFF LED #2

    // test if we need to turn ON boolean
    if( filteredResult > ampThreshold )
    {
      b_trigger = 1;  // turn ON boolean
      trigger_counter = 0; // reset
  }
}

I am brainstorming about what could be the cause of my problem. I doubt these are truly the cause of the problem, but here are some thoughts:

  1. It is not allowed to use nested-if structure. The compiler cannot handle it properly.
  2. Right now the FIR filter operates on a buffer of 'short' (16 bit integers) and convolves the buffer with the array of filter coefficients. Since the filter coefficients are stored using the 'double' precision floating point type, can this be causing some exception causing logical operators to misbehave? Remember, the output signal looks fine.
  3. Is it wrong to command an LED from within a hardware interrupt function?

System:
OS: Windows 7 64 bit
IDE: CCS 5.1
compiler: TI v7.3.4


Viewing all articles
Browse latest Browse all 123898

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>