pigpio icon indicating copy to clipboard operation
pigpio copied to clipboard

Can create SPI wave in nano seconds resolution?

Open andyzhuang2015 opened this issue 1 year ago • 10 comments

I use ADS8688A with the 500kSPS. It need 64 clock time per sample. However, the pigpio library use 1us as the min clock time. The max speed I can achieved is (1000 / 64) kSPS, which is much smaller than 500.

So how can modify the SPI clock to 10ns or 100ns ?

andyzhuang2015 avatar Aug 19 '23 10:08 andyzhuang2015

The hardware SPI supports a baud rate maximum of 32M.

guymcswain avatar Aug 19 '23 12:08 guymcswain

The hardware SPI supports a baud rate maximum of 32M.

Yes. But when use rawWaveAddSPI , the parameter rawSPI_t's clk_us min value is 1us. This limit the clock frequency to 1M. Any workaround to improve the Wave frequency? ( I need to monitor the signal in real-time. So I use Wave to exchange data by SPI. I think spiXfer may have dubious time slot between two invoking. ) @guymcswain This blocking me too much time. Will be very appreciate for your help!

andyzhuang2015 avatar Aug 19 '23 13:08 andyzhuang2015

The construction of output waveforms is limited to 1 microsecond timing. Ie, the fastest square waveform you can generate is 500 KHz.

guymcswain avatar Aug 19 '23 14:08 guymcswain

The construction of output waveforms is limited to 1 microsecond timing. Ie, the fastest square waveform you can generate is 500 KHz.

Is it possible to improve the waveforms' CLK timing to nano seconds?

andyzhuang2015 avatar Aug 19 '23 22:08 andyzhuang2015

No. Waveforms are controlled by DMA. To try to make it run sub microseconds would be futile as that would create excessive bus traffic interfering with normal activity.

Why do you not use the hardware SPI peripheral which is intended for such purposes?

guymcswain avatar Aug 20 '23 13:08 guymcswain

@guymcswain I use RPI to do this because it need no other devices and I saw that the clocks can achieve 100MHz or higher for RPI peripheral. So I want to test the max ablity of the speed. @guymcswain You said hardware SPI peripheral, did you mean using FPGA DAQ card, like NI Corporation's?

andyzhuang2015 avatar Aug 21 '23 23:08 andyzhuang2015

RPi is made up of many peripherals. The 100MHz rate you mention is only achievable in certain Gpio pins via the Clock peripheral. When I mentioned the SPI peripheral I am referring to the APIs: spiOpen, spiTransfer, spiClose.

guymcswain avatar Aug 22 '23 12:08 guymcswain

@guymcswain Thanks for your patience. I need to monitor the signal continuously without time gap between two data acquest. I tried spiOpen, spiXfer (I didn't found spiTransfer API), spiClose. But there is a dubious time gap between two spiXfer invoking. I think the System schedule to do other things in the time gap. Is there any workaround to avoid that?

andyzhuang2015 avatar Aug 22 '23 13:08 andyzhuang2015

Yes, spiXfer. When you specify a buffer of data it will be transferred without any gaps. Check you ADC device. If it can handle data that fast, it most likely can buffer the data.

guymcswain avatar Aug 22 '23 14:08 guymcswain

@guymcswain If I want to streaming the input data without any gaps, can I use spiXfer to achieve this?

andyzhuang2015 avatar Aug 27 '23 03:08 andyzhuang2015