I have a data logger using MicroPython 1.12 with a design based on the Pyboard 1.1.
I have an external SPI ADC which is a LTC1857 as shown in the datasheet below where the SPI bus speed is set to 5Mbps. There are also other SPI devices on the same bus but this should not be relevant to the problem below.
LTC1857 data sheet:
https://www.analog.com/media/en/technic ... 5789fb.pdf
The problem I am facing is that I need to read the SPI ADC at least 1kHz or more (plan to use a 500Hz or higher RC filter to prevent aliasing), but from my measurements, with the existing SPI "send_recv" method, to send 16-bit it is taking abound 45us as shown below:
Code: Select all
def sendReceive(self, sendBytes, receiveBytes, timeout):
self._setupSpiPortMain(1)
timeStart = pyb.micros()
self._spiBus.send_recv(sendBytes,
receiveBytes,
timeout=timeout)
timeEnd = pyb.micros()
print("sendReceive")
print(timeEnd - timeStart)
print(sendBytes)
I tried sending more bytes at once which improved the results but this will not work with the SPI ADC as I need to wait for the busy pin before reading the sample.
Code: Select all
def sendReceive(self, sendBytes, receiveBytes, timeout):
self._setupSpiPortMain(1)
sendBytes = bytearray([0xE8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
receiveBytes = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
timeStart = pyb.micros()
self._spiBus.send_recv(sendBytes,
receiveBytes,
timeout=timeout)
timeEnd = pyb.micros()
print("sendReceive")
print(timeEnd - timeStart)
print(sendBytes)
I would just like to know what is the best way to approach getting the SPI ADC reading happening faster given I need to call "send_recv" to read each channel waiting for the busy pin in between reads? I know there is assembly, but I will need to read up on that and ideally would like to approach this with easiest options first down to assembly. Thoughts and comments much appreciated.