Forums

Sample code for data acquisition

Started by sanjana July 16, 2003
Hi all
can anyone plz share any data acquisition code on either
SHARC/BLACKFIN processors with me....has anyone did some real time
processing on the data
while acquisting (without storing)....just some snippet...for my
understanding..
Thanks in advance
Sanajana
sanjana wrote:
> > Hi all > can anyone plz share any data acquisition code on either > SHARC/BLACKFIN processors with me....has anyone did some real time > processing on the data > while acquisting (without storing)....just some snippet...for my > understanding.. > Thanks in advance > Sanajana
I'd like to see your definition of "acquisting (without storing)." How can you acquire the signal without storing it? You have to store at least ONE sample SOMEWHERE! Most classic DSP processing (FFT, FIR, IIR) will *require* that you have more than one sample on hand before you can process it, and that implies storage. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 Air conditioning may have destroyed the ozone layer - but it's been worth it!
"sanjana" <sanjana0706@yahoo.com> wrote in message
news:ef48202a.0307161635.e089bb8@posting.google.com...
> Hi all > can anyone plz share any data acquisition code on either > SHARC/BLACKFIN processors with me....has anyone did some real time > processing on the data > while acquisting (without storing)....just some snippet...for my > understanding.. > Thanks in advance > Sanajana
Any example code will be pretty useless if it doesn't match your hardware. The DSP by itself cannot do any data acquisition. The 'acquisting' needs to be done by some kind of A/D or Codec which will then interface to the DSP. This interface will largely determine how the code manages to get the data for further processing. BTW, there is plenty of example code to do various types of processing on Analog Devices' web site. Cheers Bhaskar
I m sorry for the confusion..i should not have added that......the
task is like i have store the data from the ADC to external memory
using peripheral DMA...and DMA the data into the internal mem from the
external memory and perform FFT......while the ADC in the backgound
keeps sending the data into the ext.mem....when there are 1024 points
and i will have to DMA the data into the int.mem and do the FFt
routine.....

Jim Thomas <jthomas@bittware.com> wrote in message news:<3F16AD58.89CD13F2@bittware.com>...
> sanjana wrote: > > > > Hi all > > can anyone plz share any data acquisition code on either > > SHARC/BLACKFIN processors with me....has anyone did some real time > > processing on the data > > while acquisting (without storing)....just some snippet...for my > > understanding.. > > Thanks in advance > > Sanajana > > I'd like to see your definition of "acquisting (without storing)." How > can you acquire the signal without storing it? You have to store at > least ONE sample SOMEWHERE! Most classic DSP processing (FFT, FIR, IIR) > will *require* that you have more than one sample on hand before you can > process it, and that implies storage.
sanjana wrote:
> > I m sorry for the confusion..i should not have added that......the > task is like i have store the data from the ADC to external memory > using peripheral DMA...and DMA the data into the internal mem from the > external memory and perform FFT......while the ADC in the backgound > keeps sending the data into the ext.mem....when there are 1024 points > and i will have to DMA the data into the int.mem and do the FFt > routine.....
You could DMA it from the A/D directly to internal memory (which is what I'd do). But since you asked, I'll describe the 2-step operation: First, get your user manual ready and open it up to the chapter on DMA. If you don't have a manual, download one from ADI. Pay special attention to external port DMA's and DMA chaining. Set up a chained DMA to transfer data from the A/D to external memory. You should use two transfer control blocks (TCB's), and have them chain to one another (so when xfer A completes, it starts xfer B, and when xfer B completes, it starts xfer A). Set both of these up so that an interrupt is generated when the transfer completes. When the DMA completes, your interrupt service routine (isr) should start another DMA on another channel to move the data from external memory to internal memory. That DMA should also generate an interrupt, and THAT isr should perform (or trigger) the processing of the data in internal memory. The ext->int DMA should also involve two cross-chained TCB's so you can overlap the DMA and the processing. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 In theory, theory and practice are the same, but in practice, they're not
Jim Thomas wrote:
> > sanjana wrote: > > > > I m sorry for the confusion..i should not have added that......the > > task is like i have store the data from the ADC to external memory > > using peripheral DMA...and DMA the data into the internal mem from the > > external memory and perform FFT......while the ADC in the backgound > > keeps sending the data into the ext.mem....when there are 1024 points > > and i will have to DMA the data into the int.mem and do the FFt > > routine..... > > You could DMA it from the A/D directly to internal memory (which is what > I'd do). But since you asked, I'll describe the 2-step operation: > > First, get your user manual ready and open it up to the chapter on DMA. > If you don't have a manual, download one from ADI. Pay special > attention to external port DMA's and DMA chaining. > > Set up a chained DMA to transfer data from the A/D to external memory. > You should use two transfer control blocks (TCB's), and have them chain > to one another (so when xfer A completes, it starts xfer B, and when > xfer B completes, it starts xfer A). Set both of these up so that an > interrupt is generated when the transfer completes. > > When the DMA completes, your interrupt service routine (isr) should > start another DMA on another channel to move the data from external > memory to internal memory. That DMA should also generate an interrupt, > and THAT isr should perform (or trigger) the processing of the data in > internal memory. The ext->int DMA should also involve two cross-chained > TCB's so you can overlap the DMA and the processing.
Erk! The ext->int DMA should NOT involve two cross-chained TCB's. Instead, the A/D->ext DMA ISR should handle that. You most certainly do NOT want the ext->int DMA completion interrupt to begin another xfer, or else it will run all the time. It must be paced by the A/D->ext DMA interrupt. You WILL want it to double buffer though, but that logic should go in the isr. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 In theory, theory and practice are the same, but in practice, they're not
To be elaborate...the thing is to fire a ping(10 cycles of
sine)....and we have data coming in for 6.67ms...then we again fire a
ping......since we r using DMA to xfer data...we want to process some
of data thatz already in ..inorder not to keep the processor idle for
6.67ms(since we are doing the entire procedure for 20 times...we plan
not to lose 6.67ms*20 time..)....so we keep on moving in the data into
ext.mem and try to dma the data some of that data for processing in
that time.....

Is it possible to DMA the data from the ext.mem-->int.mem(previouly
stored data say 1024 points)when the ADC-->ext.mem DMA goes on...i m
using Blackfin...
so how do the two channels share the bandwidth.....on blackfin the max
for peripheral DMA is 133MHz and for memory DMA is 66.5Mhz....if
initited the xfer
simultaneouly....the peripheral DMA takes prority...

Any suggestions..




Jim Thomas <jthomas@bittware.com> wrote in message news:<3F17FE4E.D0792417@bittware.com>...
> sanjana wrote: > > > > I m sorry for the confusion..i should not have added that......the > > task is like i have store the data from the ADC to external memory > > using peripheral DMA...and DMA the data into the internal mem from the > > external memory and perform FFT......while the ADC in the backgound > > keeps sending the data into the ext.mem....when there are 1024 points > > and i will have to DMA the data into the int.mem and do the FFt > > routine..... > > You could DMA it from the A/D directly to internal memory (which is what > I'd do). But since you asked, I'll describe the 2-step operation: > > First, get your user manual ready and open it up to the chapter on DMA. > If you don't have a manual, download one from ADI. Pay special > attention to external port DMA's and DMA chaining. > > Set up a chained DMA to transfer data from the A/D to external memory. > You should use two transfer control blocks (TCB's), and have them chain > to one another (so when xfer A completes, it starts xfer B, and when > xfer B completes, it starts xfer A). Set both of these up so that an > interrupt is generated when the transfer completes. > > When the DMA completes, your interrupt service routine (isr) should > start another DMA on another channel to move the data from external > memory to internal memory. That DMA should also generate an interrupt, > and THAT isr should perform (or trigger) the processing of the data in > internal memory. The ext->int DMA should also involve two cross-chained > TCB's so you can overlap the DMA and the processing.
Thanks Jim .....

Jim Thomas <jthomas@bittware.com> wrote in message news:<3F17FE4E.D0792417@bittware.com>...
> sanjana wrote: > > > > I m sorry for the confusion..i should not have added that......the > > task is like i have store the data from the ADC to external memory > > using peripheral DMA...and DMA the data into the internal mem from the > > external memory and perform FFT......while the ADC in the backgound > > keeps sending the data into the ext.mem....when there are 1024 points > > and i will have to DMA the data into the int.mem and do the FFt > > routine..... > > You could DMA it from the A/D directly to internal memory (which is what > I'd do). But since you asked, I'll describe the 2-step operation: > > First, get your user manual ready and open it up to the chapter on DMA. > If you don't have a manual, download one from ADI. Pay special > attention to external port DMA's and DMA chaining. > > Set up a chained DMA to transfer data from the A/D to external memory. > You should use two transfer control blocks (TCB's), and have them chain > to one another (so when xfer A completes, it starts xfer B, and when > xfer B completes, it starts xfer A). Set both of these up so that an > interrupt is generated when the transfer completes. > > When the DMA completes, your interrupt service routine (isr) should > start another DMA on another channel to move the data from external > memory to internal memory. That DMA should also generate an interrupt, > and THAT isr should perform (or trigger) the processing of the data in > internal memory. The ext->int DMA should also involve two cross-chained > TCB's so you can overlap the DMA and the processing.
"sanjana" <sanjana0706@yahoo.com> wrote in message
news:ef48202a.0307181204.5b8f9676@posting.google.com...
> To be elaborate...the thing is to fire a ping(10 cycles of > sine)....and we have data coming in for 6.67ms...then we again fire a > ping......since we r using DMA to xfer data...we want to process some > of data thatz already in ..inorder not to keep the processor idle for > 6.67ms(since we are doing the entire procedure for 20 times...we plan > not to lose 6.67ms*20 time..)....so we keep on moving in the data into > ext.mem and try to dma the data some of that data for processing in > that time.....
Firstly, please do not abbreviate your words so much - it makes for very difficult reading. If your goal is to not waste time waiting for data, you don't need this complicated setup of sending data to external memory and copying that into internal memory for processing. Setup a chained DMA transfer from A/D to internal memory. You will have 2 buffers that are being fed by the chained DMA alternately. When 1 buffer is full, it notifies your main program and automatically switches to filling data into the 2nd buffer. Your main program takes the data from the 1st buffer and processes it. The same process repeats with the 2nd buffer and the DMA switches back to the 1st buffer. BTW, what is a 'ping'? - never heard of it in contexts other than networking and table tennis. The 2 buffers I mention are sometimes referred to as ping-pong buffers - but one doesn't fire pings (or pongs).
> > Is it possible to DMA the data from the ext.mem-->int.mem(previouly > stored data say 1024 points)when the ADC-->ext.mem DMA goes on...i m > using Blackfin... > so how do the two channels share the bandwidth.....on blackfin the max > for peripheral DMA is 133MHz and for memory DMA is 66.5Mhz....if > initited the xfer > simultaneouly....the peripheral DMA takes prority... > > Any suggestions.. > > > > > Jim Thomas <jthomas@bittware.com> wrote in message
news:<3F17FE4E.D0792417@bittware.com>...
> > sanjana wrote: > > > > > > I m sorry for the confusion..i should not have added that......the > > > task is like i have store the data from the ADC to external memory > > > using peripheral DMA...and DMA the data into the internal mem from the > > > external memory and perform FFT......while the ADC in the backgound > > > keeps sending the data into the ext.mem....when there are 1024 points > > > and i will have to DMA the data into the int.mem and do the FFt > > > routine..... > > > > You could DMA it from the A/D directly to internal memory (which is what > > I'd do). But since you asked, I'll describe the 2-step operation: > > > > First, get your user manual ready and open it up to the chapter on DMA. > > If you don't have a manual, download one from ADI. Pay special > > attention to external port DMA's and DMA chaining. > > > > Set up a chained DMA to transfer data from the A/D to external memory. > > You should use two transfer control blocks (TCB's), and have them chain > > to one another (so when xfer A completes, it starts xfer B, and when > > xfer B completes, it starts xfer A). Set both of these up so that an > > interrupt is generated when the transfer completes. > > > > When the DMA completes, your interrupt service routine (isr) should > > start another DMA on another channel to move the data from external > > memory to internal memory. That DMA should also generate an interrupt, > > and THAT isr should perform (or trigger) the processing of the data in > > internal memory. The ext->int DMA should also involve two cross-chained > > TCB's so you can overlap the DMA and the processing.
Bhaskar Thiagarajan wrote:
> > "sanjana" <sanjana0706@yahoo.com> wrote in message > news:ef48202a.0307181204.5b8f9676@posting.google.com... > > To be elaborate...the thing is to fire a ping(10 cycles of > > sine)....and we have data coming in for 6.67ms...then we again fire a > > ping......since we r using DMA to xfer data...
...
> > Firstly, please do not abbreviate your words so much - it makes for very > difficult reading.
... Sanjana too should read http://users.erols.com/jyavins/procfaq.htm
> > BTW, what is a 'ping'? - ...
An active sonar pulse, as far as I know. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;