Hi guys,
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.
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