EmbeddedRelated.com
Forums

Fast SPI (SSP0) transfer to get ADC data

Started by Henry September 13, 2012
Hello to all,

I intend to sample 4 analog input signals with an ADS1274.
ADS1274 outputs 4*24 bits on a serial pin in SPI format ( alternatively in frame sync format) and also outputs /DRDY to indicate that valid data is available.
The idea is to use SPI (SSP0 interface) of a LPC2468 as a master.
/DRDY shall start an interrupt service routine that reads the data via the SPI interface.
An evaluation board has been connected and it is possible to read sampled data from 1 channel so far.

The problem is that only 14.2s (sample rate 70.3125kHz) are available to read these 12 bytes.
The normal way to read the data would consist of 3 steps:
- the master transmits a dummy byte and outputs SCLK
SSP0DR = 0xFF;
- wait until the SSPn controller is idle
while ( (SSP0SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
- read the byte and store it
*buf++ = SSP0DR;

Runnig through this procedure for 12 bytes would take about 20s (a bit less I assume).

Perhaps a way out of that problem might be one of the following:
1. Programming these 3 steps above in assemler code, which might reduce time slightly
2. Transfering received data in DMA mode.
But that still would mean to send a dummy byte and wait for the idle state before the next dummy byte can be sent.
Most likely this will not reduce time sufficiently, I am afraid.
3. continuous back-to-back transfers
The manual of LPC2468 mentions that continuous back-to-back transfer is possible
But I did not find a note on where to set this continuous back-to-back transfer mode.
What is said in the manual is this:
"For continuous back-to-back transfers, the SSEL pin is held LOW between successive
data words and termination is the same as that of the single word transfer."
SSEL is not needed for ADS1274.
Perhaps there is a way to activate SCLK continuously for the transfer of say 6 bytes and read these bytes one after the other without sending a dummy byte from the master each time. Does anybody know more about that?

4. The ADS1274 can output sampled data simultaneously for each channel (4 separate pins). This would require additional hardware and I have no idea if there are appropriate circuits (ics) available.

Can anybody tell from his experience how such a problem could be solved?
Any hint is highly welcome!

Regards,
Henry

An Engineer's Guide to the LPC2100 Series

> I intend to sample 4 analog input signals with an ADS1274.
> ADS1274 outputs 4*24 bits on a serial pin in SPI format ( alternatively in
> frame sync format) and also outputs /DRDY to indicate that valid data is
> available.
> The idea is to use SPI (SSP0 interface) of a LPC2468 as a master.
> /DRDY shall start an interrupt service routine that reads the data via the
> SPI interface.
> An evaluation board has been connected and it is possible to read sampled
> data from 1 channel so far.
>
> The problem is that only 14.2s (sample rate 70.3125kHz) are available to
> read these 12 bytes.
> The normal way to read the data would consist of 3 steps:
> - the master transmits a dummy byte and outputs SCLK
> SSP0DR = 0xFF;
> - wait until the SSPn controller is idle
> while ( (SSP0SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
> - read the byte and store it
> *buf++ = SSP0DR;

I believe the SPI is based on the PL022 IP from ARM.

4*24 bits = 96 bits. 16 divides 96. Hence, put SSP0 in 16-bit mode, not
8-bit mode, to transfer 16 bits at a time.

The SSP has a large-ish FIFO. Hence, write 0x0000 to the FIFO 6 times.
Poll and drain 6 16-bit words from the receiver.

If the 1274 works like the 7846, which I have programmed, then reading
requires you to send 0x0000 to receive the bytes otherwise the most
significant bit set indicates a command being sent.

Regards,

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com

Hello Paul,

that solved the problem. There even is enough time to store the data immediately, no need for DMA.

Thank you very much!
Regards,
Henry

--- In l..., "Paul Curtis" wrote:
>
> > I intend to sample 4 analog input signals with an ADS1274.
> > ADS1274 outputs 4*24 bits on a serial pin in SPI format ( alternatively in
> > frame sync format) and also outputs /DRDY to indicate that valid data is
> > available.
> > The idea is to use SPI (SSP0 interface) of a LPC2468 as a master.
> > /DRDY shall start an interrupt service routine that reads the data via the
> > SPI interface.
> > An evaluation board has been connected and it is possible to read sampled
> > data from 1 channel so far.
> >
> > The problem is that only 14.2s (sample rate 70.3125kHz) are available to
> > read these 12 bytes.
> > The normal way to read the data would consist of 3 steps:
> > - the master transmits a dummy byte and outputs SCLK
> > SSP0DR = 0xFF;
> > - wait until the SSPn controller is idle
> > while ( (SSP0SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
> > - read the byte and store it
> > *buf++ = SSP0DR;
>
> I believe the SPI is based on the PL022 IP from ARM.
>
> 4*24 bits = 96 bits. 16 divides 96. Hence, put SSP0 in 16-bit mode, not
> 8-bit mode, to transfer 16 bits at a time.
>
> The SSP has a large-ish FIFO. Hence, write 0x0000 to the FIFO 6 times.
> Poll and drain 6 16-bit words from the receiver.
>
> If the 1274 works like the 7846, which I have programmed, then reading
> requires you to send 0x0000 to receive the bytes otherwise the most
> significant bit set indicates a command being sent.
>
> Regards,
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> SolderCore Development Platform http://www.soldercore.com
>

>
> Hello Paul,
>
> that solved the problem. There even is enough time to store the data
> immediately, no need for DMA.
>
> Thank you very much!
> Regards,
> Henry

You're welcome.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com