This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Fast ADC using the PRU to bitbang SPI

Prodigy 80 points

Replies: 3

Views: 1212

Hi,

I would like to know if someone here has already tried bitbanging SPI with the PRU units? 
I have a 12bit ADC (TI ADS7883) which takes a clock signal and outputs 12 bits of data, and I would like to use the PRU to achieve high sampling rate.
See http://www.ti.com/lit/ds/symlink/ads7883.pdf for the ADC documentation with the interface timing diagram.
Basically, the PRU program would do the following (assuming a cycle time of 5ns and one cycle for each line of the loop):
- Initiate 3 GPIO channels (2 outputs: SCLK and CS, 1 input: SDO)
- Allocate memory (a lot! I'd like to capture millions of samples)
Loop for N samples:
- Pull CS high
- Wait 3 cycles
- Pull SCLK high
- Wait 2 cycles
- Pull CS low (initiate output)
- Wait 2 cycles
- Pull SCLK low
- Wait 5 cycles
- Pull SCLK high
- Wait 5 cycles
- Pull SCLK low
- Wait 5 cycles
- Pull SCLK high
- Wait 5 cycles
- Pull SCLK low
- Read SDO (first bit)
- Store it somewhere
- Wait 3 cycles
- Pull SCLK high
- Wait 5 cycles
- Pull SCLK low
- Read SDO (2nd bit)
- Store it somewhere
- Wait 3 cycles
- Pull SCLK high
- Wait 5 cycles
- Pull SCLK low
- Read SDO (3rd bit)
- Store it somewhere  ... and so on until 12th bit
- Wait 60ns (acquisition time) while always pulling CLK high and low every 6 cycles
End of loop
The problem is that I have never programmed in assembly code. I have tried looking at examples but have a really hard time understanding the simplest commands (ex: what is a simple MOV r3, 1<<7 doing?).
I'd like to have a thoroughly commented, simple example to start if possible. 
Memory issues are also a big problem. How can I store all the captured data so that it is fast and doesn't overflow the PRU memory?
Many thanks for your help!
Touste

3 Replies

  • Hi Baptiste,

    What is the sampling rate you want to achieve? Isn't it possible to do this with standard McSPI peripheral? I don't think there are ready examples of doing this with PRU.

     

    Best Regards
    Biser
  • In reply to Biser Gatchev-XID:

    Hi Biser,

    Thanks for your help. I would like to achieve a minimum sampling rate of 1 MSPS, and if possible in a "real-time" way, i.e. the time between two samples should always be the same. 

    Is it possible with standard McSPI peripheral? If so, it would make things easier I think. Do you have a link to relevant online resources to get me started?

    Many thanks

    Baptiste

  • In reply to Baptiste Pierrat:

    The McSPI can go up to 48MHz clock, however I don't think that what you want to achieve will be possible under Linux. You might want to check the Starterware package, which is an OS-less environment: http://processors.wiki.ti.com/index.php/StarterWare

     

    Best Regards
    Biser

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.