cancel
Showing results for 
Search instead for 
Did you mean: 

DMA ADC Bit shift

fabio1
Associate II
Posted on March 29, 2014 at 09:18

I am using DMA to transfer ADC data to a uint16 variable @ 1MS/s

Than the value is shifted with another DMA channel to SPI and sent to an external DAC.

Unfortunately the external 14 bit  ADC does not allow for left aligned or right aligned data, the MSBs are control bits  <c0><c1><data:14> and the ADC value are 12 bits and I can't align the data correctly.

Is there any way to shift the incoming ADC data left or right in DMA mode? I tried using unions with no success.

Fabio

 
3 REPLIES 3
Posted on March 29, 2014 at 12:31

Unions are a software construct the DMA engine isn't going to understand them. The ADC uses addresses to select barrel shifters.

The way your data is aligned it sounds as if you're going to have to do a software pass on them to shift the data into the correct position, either 2 left or right, rather than the 4 the hardware can effect.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fabio1
Associate II
Posted on March 29, 2014 at 15:14

Thanks Clive,

this was indeed my nightmare...

The Union cannot help because the DMA destination address cannot be bit aligned but uint32,

Processing the bit alignment in software makes DMA not longer helpful but needs severe interrupt processing, not really feasible , I think @ 1Ms/s

Now I am using a CPLD for this and others, wanted to get rid of it, may be somebody can help me....

Fabio

 

zzdz2
Associate II
Posted on March 29, 2014 at 15:27

Processing the bit alignment in software makes DMA not longer helpful but needs severe interrupt processing, not really feasible , I think @ 1Ms/s

 

You don't need to process one sample per interrupt, you can buffer it and process in bulk, e.g. 1k samples per irq.

I guess 1MS/s would take something like 10M CPU cycles per second.