I successfully drive a DAC via SPI using the spidev native SPI driver using a RaspberryPi3. The core portion of my code is as follows:
fd = open("/dev/spidev0.0", O_RDWR); txarr=0xAA; txarr=0x01; trstruct.tx_buf = (unsigned long)txarr; ioctl(fd, SPI_IOC_MESSAGE(1), &trstruct);
It works ok, but timing is far from what I was expecting. Inspecting the SPI signals shows the following (top trace is chip select, mid trace is data and bottom trace is SCLK): As we can see, the chip select is asserted low far before data transfer(about 6.5us earlier, and data transfer lasts just 1.9us). This behavior voids the benefits of using SPI at high speeds when multiple subsequent data transfers are needed.
Any idea how to speed up the chip select assertion low and to minimize its lasting low after data transfer is finished ?
Many thanks in advance, Marco