I have an application where I want to write to an external DAC and read from an external ADC using the pi's SPI interface continuously.
The data to the DAC could come from some arbitrary function, and the result from the ADC I want to put into a file for later post-processing.
I have done this using the spidev module in python, and this works fine. However, the application requires the timing for both transactions to be consistent, i.e. happening exactly every 1 ms, so I can't just do a:
i = 0 while True: myADCfile.write(spi.readbytes(16)) spi.writebytes(arb_function(i)) time.sleep(0.001) i += 1
Because then the timing will depend on the CPU's priorities..
According to the broadcom documentation , the pi has a DMA that can control the SPI. However, I can't figure out how to set this up, and I haven't found any examples.
Can anyone point me to an example (preferably in python), or some resources on this?