DSPRelated.com
Forums

Sr. Project with c6713

Started by carl_brysch March 28, 2007
My project is to activate an LED when a police siren is detected for
emergency purposes. Signal is coming in from a microphone to "line
in". I am using a bandpass filter to detect the good frequency (ex.
200Hz). I am using this program to put data into a buffer (yn).

//FIRbuf.c FIR filter with output in buffer

#include "DSK6713_AIC23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include "bp41.cof" //BP @ 1 kHz coefficient file
int yn = 0; //initialize filter's output
short dly[N]; //delay samples
short buffercount = 0; //init buffer count
const short bufferlength = 1024; //buffer size
short yn_buffer[1024]; //output buffer

interrupt void c_int11() //ISR
{
short i;
dly[0]=input_sample(); //input newest sample
yn = 0;
//initialize filter's output
for (i = 0; i< N; i++)
yn +=(h[i]*dly[i]) >>15; //y(n)+=h(i)*x(n-i) ~?>>15?
for (i = N-1; i > 0; i--) //start @ bottom of buffer
dly[i] = dly[i-1];
//data move to update delays
output_sample((short)yn); //output filter
yn_buffer[buffercount] = yn; //filter's output into buffer
buffercount++;
//increment buffer count
if(buffercount==bufferlength) buffercount=0; //re buffer count
printf("%d", yn);
return;
//return from interrupt
}

void main()
{
comm_intr();
//init DSK, codec, McBSP
while(1);
//infinite loop
}
My question is, how can I evaluate the ATD values after they are
saved to the buffer, or is this even possible?. Then... If the
values are large enough, I want to turn on an LED, indicating
emergency.

If anyone can help I would greatly appreciate it! I only have 3
weeks to finish my project.

Sincerely,

Carl
Carl-

> You said:
>
> >you would want the ISR to simply handle a "DMA buffer full" event, with
> >your FIR filtering and other signal processing handled in lower priority
> >threads.
>
> When the buffer is full, im guessing an overflow flag gets set? So how
> would I check for the "DMA buffer full" event?

I was referring to significant changes you would have to make, such as instantiating
EDMA, using CSL and possibly DSP/BIOS, changing your ISR-thread relationship, etc.
These are notes for you to consider, but I strongly recommend not to do any of that
now. You have the code working and my suggestion would be get the results your Prof
wants, and then if you still have time and inspiration, improve your code
architecture one step at a time.

> Also, how could I see the
> values that are being saved to the buffer (yn)? I tried to "printf" the
> contents of (yn), but only received garbage from Code composer studio.

Do not use printf() for anything inside an ISR. Try log_printf() instead. But even
then you have to be very careful about what you ask CCS to do with code inside an
ISR.

> Would this be done with a GEL file? Is there a command for a software
> interrupt, where I could then view the contents of the memory location for
> (yn)?

Gel file doesn't apply here, that's more of tool for configuration, initialization
and self-test. All you need to do is set a breakpoint on some condition (buffer
full? number of buffers?) and then you can use a memory view window to see your
data. You're making it too hard.

> The ADC will output some values from the converted input signal (ex.
> 0-255). I want to set a threshold of say... above 100 to be considered a
> "good received signal" then turn on the LED. I then want to program some
> type of "compare" to the predetermined threshold value. If the signal value
> is above the threshold value, turn on LED. Is this possible?

Sure, just program it. If your code is working as you say it is, then the values are
collecting in your buffer yelling out "ready to be processed". When the buffer is
full, add up the squares of the values, take average and squareroot (look up 'RMS'),
and output a GPIO to turn on your LED if it's above a threshold. You can put a
breakpoint inside the LED code.

-Jeff
> > My project is to activate an LED when a police siren is detected for
> > emergency purposes. Signal is coming in from a microphone to "line
> > in". I am using a bandpass filter to detect the good frequency (ex.
> > 200Hz). I am using this program to put data into a buffer (yn).
> >
> > //FIRbuf.c FIR filter with output in buffer
> >
> > #include "DSK6713_AIC23.h" //codec-DSK support file
> > Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
> > #include "bp41.cof" //BP @ 1 kHz coefficient file
> > int yn = 0; //initialize filter's output
> > short dly[N]; //delay samples
> > short buffercount = 0; //init buffer count
> > const short bufferlength = 1024; //buffer size
> > short yn_buffer[1024]; //output buffer
> >
> > interrupt void c_int11() //ISR
> > {
> > short i;
> > dly[0]=input_sample(); //input newest sample
> > yn = 0;
> > //initialize filter's output
> > for (i = 0; i< N; i++)
> > yn +=(h[i]*dly[i]) >>15; //y(n)+=h(i)*x(n-i) ~?>>15?
> > for (i = N-1; i > 0; i--) //start @ bottom of buffer
> > dly[i] = dly[i-1];
> > //data move to update delays
> > output_sample((short)yn); //output filter
> > yn_buffer[buffercount] = yn; //filter's output into buffer
> > buffercount++;
> > //increment buffer count
> > if(buffercount==bufferlength) buffercount=0; //re buffer count
> > printf("%d", yn);
> > return;
> > //return from interrupt
> > }
> >
> > void main()
> > {
> > comm_intr();
> > //init DSK, codec, McBSP
> > while(1);
> > //infinite loop
> > }
> >
> > My question is, how can I evaluate the ATD values after they are
> > saved to the buffer, or is this even possible?. Then... If the
> > values are large enough, I want to turn on an LED, indicating
> > emergency.
> >
> > If anyone can help I would greatly appreciate it! I only have 3
> > weeks to finish my project.
>
>Carl-
>
>You've already got a lot of code in your ISR, so why not add some code that
>looks
>through yn_buffer[] and makes some type of energy or average magnitude
>measurement?
>
>As a note, for a real-world system that maximizes robustness and real-time
>processing
>capacity, you would want the ISR to simply handle a "DMA buffer full"
>event, with
>your FIR filtering and other signal processing handled in lower priority
>threads. As
>it is, you're locking up the system in a high-priority ISR for a long time.
> This is
>ok for now, since it's an academic project and you need to get it working
>under the
>deadline.
>
>Also, what is ATD?
>
>-Jeff

Jeff, thanks for your reply.
By ATD I should have said the ADC or, analog to digital converter. Sorry
for the confusion.
You said:

>you would want the ISR to simply handle a "DMA buffer full" event, with
>your FIR filtering and other signal processing handled in lower priority
>threads.

When the buffer is full, im guessing an overflow flag gets set? So how
would I check for the "DMA buffer full" event? Also, how could I see the
values that are being saved to the buffer (yn)? I tried to "printf" the
contents of (yn), but only received garbage from Code composer studio.
Would this be done with a GEL file? Is there a command for a software
interrupt, where I could then view the contents of the memory location for
(yn)?

The ADC will output some values from the converted input signal (ex.
0-255). I want to set a threshold of say... above 100 to be considered a
"good received signal" then turn on the LED. I then want to program some
type of "compare" to the predetermined threshold value. If the signal value
is above the threshold value, turn on LED. Is this possible?

Thanks for your help!

Carl

_________________________________________________________________
Mortgage refinance is hot 1) Rates near 30-yr lows 2) Good credit get
intro-rate 4.625%*
https://www2.nextag.com/goto.jsp?product0000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h2a5f&s@56&pQ17&disc=y&verst3
Carl-

> My project is to activate an LED when a police siren is detected for
> emergency purposes. Signal is coming in from a microphone to "line
> in". I am using a bandpass filter to detect the good frequency (ex.
> 200Hz). I am using this program to put data into a buffer (yn).
>
> //FIRbuf.c FIR filter with output in buffer
>
> #include "DSK6713_AIC23.h" //codec-DSK support file
> Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
> #include "bp41.cof" //BP @ 1 kHz coefficient file
> int yn = 0; //initialize filter's output
> short dly[N]; //delay samples
> short buffercount = 0; //init buffer count
> const short bufferlength = 1024; //buffer size
> short yn_buffer[1024]; //output buffer
>
> interrupt void c_int11() //ISR
> {
> short i;
> dly[0]=input_sample(); //input newest sample
> yn = 0;
> //initialize filter's output
> for (i = 0; i< N; i++)
> yn +=(h[i]*dly[i]) >>15; //y(n)+=h(i)*x(n-i) ~?>>15?
> for (i = N-1; i > 0; i--) //start @ bottom of buffer
> dly[i] = dly[i-1];
> //data move to update delays
> output_sample((short)yn); //output filter
> yn_buffer[buffercount] = yn; //filter's output into buffer
> buffercount++;
> //increment buffer count
> if(buffercount==bufferlength) buffercount=0; //re buffer count
> printf("%d", yn);
> return;
> //return from interrupt
> }
>
> void main()
> {
> comm_intr();
> //init DSK, codec, McBSP
> while(1);
> //infinite loop
> }
>
> My question is, how can I evaluate the ATD values after they are
> saved to the buffer, or is this even possible?. Then... If the
> values are large enough, I want to turn on an LED, indicating
> emergency.
>
> If anyone can help I would greatly appreciate it! I only have 3
> weeks to finish my project.

You've already got a lot of code in your ISR, so why not add some code that looks
through yn_buffer[] and makes some type of energy or average magnitude measurement?

As a note, for a real-world system that maximizes robustness and real-time processing
capacity, you would want the ISR to simply handle a "DMA buffer full" event, with
your FIR filtering and other signal processing handled in lower priority threads. As
it is, you're locking up the system in a high-priority ISR for a long time. This is
ok for now, since it's an academic project and you need to get it working under the
deadline.

Also, what is ATD?

-Jeff