This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using external SPI ADC on nRF5340

Hi, 

I need close to 1Msps rates for my application and am planning on using a ADS7887 SPI ADC from TI.  My question is on how to drive the SPIM and if an example exists to do this.

These SPI ADCs start the 16 bit collection on a lower going chip select.  I assume that the way to collect data is to configure EasyDMA to collect two bytes and to have a timer drive the SPI task at a rate of approx 1Msps?  So I would have to collect to start the SPI task, collect two bytes, restart the tast etc.

Or is there some way to configure the SPIM for this specific purpose where the chip select could be driven automatically so I can simply say collect 10K samples and the processor would handle the SPI CS signaling? 

Thanks

Parents
  • Hi,

    1 Msps seems like much, especially if you need to also process the data at some point. Will every 16 bit sample be a separate SPI transaction? If so, you may want to look into the Easy DMA list feature (see SPIM chapter in product specification). If not and you just stream data, then you can set the DMA buffer to a sensible size and get a interrupt once the buffer is filled and you process the data, while another buffer is being filled. 

    The SPIM peripheral on the nRF53 supports controlling the CS line in HW. Alternatively you could also control it from a TIMER or using PPI and GPIOTE, depending on what fits your requirements.

    You may also want to look into the nrfx_spim driver API: https://github.com/NordicSemiconductor/nrfx/blob/master/drivers/include/nrfx_spim.h

  • Hi Einar, 

    The 1Msps is required for the application unfortunately.  What we would like to do is to collect 1K samples as easy as possible ideally without without firmware intervention. Once samples are collected then I can take as much time as possible to process.  I need my sample rate to be very precise.   Let me know if this is correct.

    1. Using Easy DMA list I set the pointer and size of the buffer. 

    2. I enable the SHORTS register, start my SPIM task with RX buffer set to two bytes. 

    3. On End event data will be written automatically and the Easy DMA list feature will update the pointer. 

    4. The SHORTS will then restart the SPIM task?  

    I probably have this wrong but getting closer. 

  • Hi,

    This seems mostly sensible. However, unless you want to transfer data as fast as possible you may want to use a TIMER to trigger the START task and not a short between END and START.

  • Hi Einar, 

    We are new to Nordic and have our nRF9160 and nRF5340 kits on the way so initial experience is going to determine whether we use Nordic in our product.  We want to reduce our learning curve as much as possible.  Instead of me guessing/proposing would it be possible to use your expertise and write down the exact steps so we need to take to accomplish this task of reading ADC values via the SPI port? 

    Thanks in advance.   

  • Yes, I can try to explain more. But for that, please clarify precisely how the SPI transaction(s) should be including timing, CS etc. I do not know your ADC IC so please explain in detail seen form SPI. Also explain how sampling is triggered. Should you read 2 bytes at a regular frequency (sampling frequency), read x bytes in bursts how often, etc.

  • Hi Einar, 

    The ADC collects 16 bits on per CS period, kicked off by a falling edge CS. 

    There is a 10nS setups time from CSlow to SCLKlow. 

    The CS signal must stay high a min of 40nS after 16 SCLKs 

    See the image below. 

    We want to get as close to 1Msps as possible.  I want to collect 5K data samples.  

    The idea is to drive CS (start of SPI task) with a timer and I believe use EasyDMA ist functions.  

    Thanks for your help, 

    Sergio

  • Hi Sergio,

    I see. Then this should be possible the way you describe. You need to use array list. Then use a timer to control CS via PPI and GPIOTE and also to trigger the START task. You probably want to use a separate CC register for this as the START task needs to be triggered a little later depending on what timing you need. Then also reset the timer on this. This way there will be no CPU intervention needed while sampling the whole set of sample, only for setting it up (and for any subsequent processing).

Reply
  • Hi Sergio,

    I see. Then this should be possible the way you describe. You need to use array list. Then use a timer to control CS via PPI and GPIOTE and also to trigger the START task. You probably want to use a separate CC register for this as the START task needs to be triggered a little later depending on what timing you need. Then also reset the timer on this. This way there will be no CPU intervention needed while sampling the whole set of sample, only for setting it up (and for any subsequent processing).

Children
No Data
Related