LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

Blackfin Multiple SPI Devices

Solved!
Go to solution

Hi NicB:

 

I don't know why but with your program I wasn't able to have SCLK or SS, don't know why, so I build one from your base code and your ideas.

The result was:

      when using circular buffer [512 / 1 / 2 / Sub Buffer] sometimes I get a callback, but very randomly and slow.

      when using Init 1D Buffer [1 / 2] and 512 Chained Buffers, it didn't callback at all.

Here is the main code (I tried other buffertype too), the callback only do Data Ready = True:

 main.jpg

Thanks for everything, once more, I'll move to PPI now!

Just one thing AD7476A only operates in SPI mode, I'll use AD7938 because it has built in 8 ADC's and sequencer, so I can read all of them one sample for each one, amazing 😛 I hope coding in PPI not to be very hard..

Regards,

António Veríssimo de Freitas
Universidade de Aveiro Student
0 Kudos
Message 11 of 19
(5,136 Views)
By the way, if you have some PPI example I would appreciate it!
António Veríssimo de Freitas
Universidade de Aveiro Student
0 Kudos
Message 12 of 19
(5,134 Views)

Sometimes my brain gets frozen mode..

I can simply use SPI with only one Slave Select and use an ADC with sequencer (you said that in option #3), they come in a single IC (8 ADC's plus sequencer) and seems easy to use.

I'll choose ADC later (ADI site is down) and start the design, I'll post results asap.

Regards,

António Veríssimo de Freitas
Universidade de Aveiro Student
0 Kudos
Message 13 of 19
(5,123 Views)
 

I was very busy so I shall reply to all posts here.

 


freitas wrote:

I don't know why but with your program I wasn't able to have SCLK or SS, don't know why, so I build one from your base code and your ideas.

The result was:

      when using circular buffer [512 / 1 / 2 / Sub Buffer] sometimes I get a callback, but very randomly and slow.

      when using Init 1D Buffer [1 / 2] and 512 Chained Buffers, it didn't callback at all.

Here is the main code (I tried other buffertype too), the callback only do Data Ready = True:



There are some wrong assumptions in my code. It seems I had forgotten how ADI buffers work in LabVIEW and pros/cons of using them :).


freitas wrote:
Just one thing AD7476A only operates in SPI mode, I'll use AD7938 because it has built in 8 ADC's and sequencer, so I can read all of them one sample for each one, amazing 😛 I hope coding in PPI not to be very hard.

 

I would use AD7938 as a memory mapped peripheral and not with PPI

Just to clarify things regarding my PPI proposal, here it is a diagram (they are serial ADCs, as AD7476A)

serial ADCs to PPI.PNG

And another kinf of diagram to get actual samples after reading 16 bytes

 

 transpose bit array to restore samples from serial ADCs after PPI read.PNG

 


freitas wrote:

Sometimes my brain gets frozen mode..

I can simply use SPI with only one Slave Select and use an ADC with sequencer (you said that in option #3), they come in a single IC (8 ADC's plus sequencer) and seems easy to use.

I'll choose ADC later (ADI site is down) and start the design, I'll post results asap.

Regards,


Note, you need to send the configuration register for next conversion while reading the current one. I would use SPI in chained loopback mode.
- One transmit buffer filled with config for
  AD2, AD3, AD4, AD1 (for 4 inputs)
- One receive buffer, or two chained (of course, element count has to be multiple of inputs #).

 

Regards

 

 

Message 14 of 19
(5,108 Views)

Hi NicB:

 

Thanks for your posts! I'll try this way, as it looks the easy one, if it doesn't work I'll move to your solution:

 

using SPI ADC AD7928 with sequencer!

link: http://www.analog.com/en/analog-to-digital-converters/ad-converters/ad7928/products/product.html

 

It's programmable, and once programmed it will change the channel of ADC in each CS! I can configure it for example to sequence only 6 ADC's or use 7 and the 7th for sync!

 

Just one thing, is there any docs to explain the labview buffers (circular, chained, chained with loopback)!

I don't know the best one to use, since I want anything close to Real Time Analysis (old data beeing wasted), and I don't know the difference between chained and chained with loopback..

 

Regards,

António Veríssimo de Freitas
Universidade de Aveiro Student
0 Kudos
Message 15 of 19
(5,106 Views)

 


freitas wrote:

Just one thing, is there any docs to explain the labview buffers (circular, chained, chained with loopback)!

I don't know the best one to use, since I want anything close to Real Time Analysis (old data beeing wasted), and I don't know the difference between chained and chained with loopback..

 



Actually they are ADI buffers not labview ones. Bellow there is an usage example, for more information see Deciding on a Dataflow Method/section 10 of VisualDSP++ 5.0 Device Drivers and System Services Manual for Blackfin Processors (select download from here, along with other manuals).

 


freitas wrote: 

Just one thing, is there any docs to explain the labview buffers (circular, chained, chained with loopback)!

I don't know the best one to use, since I want anything close to Real Time Analysis (old data beeing wasted), and I don't know the difference between chained and chained with loopback..



Probably you are asking about a double buffering technique - process a frame while the other is being acquired. Of course, the only real-time involved here is to finish processing data before next set of samples arrives.
Let’s particularize this to your application:

  • open SPI as input with DMA.
  • set Dataflow Method as chained with loopback (3) - buffer 1 will be filled, then buffer 2, and start from the beginning 1,2,1,2...-control SPI peripheral as described in ADC datasheet (CPHA=0, 16 bit, etc) (Program Files\Analog Devices\VisualDSP 5.0\Blackfin\lib\src\drivers\adc\adi_ad7476a.c/Line 221 might help you here)
  • initialize two 1D buffers, setting the callback parameter, and pass the buffers to Read SPI
 
chainning buffers in SPI driver.PNG

I would not recommend something like this (that is the main issue forgotten in application posted previously).

Init 1D with 2 num chained.PNG

Of course, it seems we have two buffers but there is only one with two descriptors (this result into an interesting behavior, sometime useful, in some applications).

  • start the dataflow
  • wait for buffers (I recommend using "BF SPI Get Callback Arguments" in interrupts)
  • process the buffers as their references are passed from interrupts.



freitas wrote:
 

using SPI ADC AD7928 with sequencer!

link: http://www.analog.com/en/analog-to-digital-converters/ad-converters/ad7928/products/product.html

 

It's programmable, and once programmed it will change the channel of ADC in each CS! I can configure it for example to sequence only 6 ADC's or use 7 and the 7th for sync!

 


If you want to use shadow register I would recommend opening SPI first for writing and then close and reopening for reading.

 

Message Edited by NicB on 09-21-2009 11:38 AM
0 Kudos
Message 16 of 19
(5,100 Views)

Some "old" update:

 

It's possible to select each Slave Select for writing only one time faster, I managed to config it with SCLK = 1MHz...

Despite this looks very good, it is not... the true SPS (Samples Per Second) was about 300Hz, because after writing and/or reading to SPI the wait time after that is very huge.. However this can be usefull...

I'll continue to work, to post some updates!

Regards,

 

P.S. - here is the main thing: (this is based on SPI and UART example, they use BF Device Wait Buffer...)

António Veríssimo de Freitas
Universidade de Aveiro Student
0 Kudos
Message 17 of 19
(5,032 Views)

Hi everyone: 

 

Here I send you a .vi to configure the AD7928 from Analog Devices, 8-channel SPI ADC with sequencer!

It was based on SPI_and_UART example!

Good Luck for using multiple SPI devices 😛

Regards,

 

P.S. - one special thank to NicB 😉

António Veríssimo de Freitas
Universidade de Aveiro Student
Download All
Message 18 of 19
(4,946 Views)

Thanks for turning back and sharing your results.
0 Kudos
Message 19 of 19
(4,932 Views)