Skip to main content
added 18 characters in body
Source Link
Bex
  • 2.9k
  • 3
  • 26
  • 34

I managed to successfuly read packets from MCP3208 ADC using SPI on Raspberry Pi - I can do that both with spidev.hspidev.h library or with WiringPi. 

The problem is that when I want much higher speed, I can preload - say - 1000 queries into an array (each query is 3 bytes) and fire it all up at once with wiringPiSPIDataRW function. In theory I should get 1000 samples as fast as possible, but unfortunately it doesn't work like that. 

According to the datasheet, before each read (query) I need to set up chip select to high for at least one clock cycle. Unfortunately I don't seem to have any control over the chip select pin while the read/write sequence is fired, so the question is - is there some mode that will fire the chip select every n bytes? 

Or if not, what other fast ways are there to read data from SPI? 

Without reading multiple bytes in a single read/write sequence, it gets pretty slow - about 60kHz and I need more than that.

I managed to successfuly read packets from MCP3208 ADC using SPI on Raspberry Pi - I can do that both with spidev.h library or with WiringPi. The problem is that when I want much higher speed, I can preload - say - 1000 queries into an array (each query is 3 bytes) and fire it all up at once with wiringPiSPIDataRW function. In theory I should get 1000 samples as fast as possible, but unfortunately it doesn't work like that. According to the datasheet, before each read (query) I need to set up chip select to high for at least one clock cycle. Unfortunately I don't seem to have any control over the chip select pin while the read/write sequence is fired, so the question is - is there some mode that will fire the chip select every n bytes? Or if not, what other fast ways are there to read data from SPI? Without reading multiple bytes in a single read/write sequence, it gets pretty slow - about 60kHz and I need more than that.

I managed to successfuly read packets from MCP3208 ADC using SPI on Raspberry Pi - I can do that both with spidev.h library or with WiringPi. 

The problem is that when I want much higher speed, I can preload - say - 1000 queries into an array (each query is 3 bytes) and fire it all up at once with wiringPiSPIDataRW function. In theory I should get 1000 samples as fast as possible, but unfortunately it doesn't work like that. 

According to the datasheet, before each read (query) I need to set up chip select to high for at least one clock cycle. Unfortunately I don't seem to have any control over the chip select pin while the read/write sequence is fired, so the question is - is there some mode that will fire the chip select every n bytes? 

Or if not, what other fast ways are there to read data from SPI? 

Without reading multiple bytes in a single read/write sequence, it gets pretty slow - about 60kHz and I need more than that.

Source Link

Setting SPI chip select every few bytes with buffered read

I managed to successfuly read packets from MCP3208 ADC using SPI on Raspberry Pi - I can do that both with spidev.h library or with WiringPi. The problem is that when I want much higher speed, I can preload - say - 1000 queries into an array (each query is 3 bytes) and fire it all up at once with wiringPiSPIDataRW function. In theory I should get 1000 samples as fast as possible, but unfortunately it doesn't work like that. According to the datasheet, before each read (query) I need to set up chip select to high for at least one clock cycle. Unfortunately I don't seem to have any control over the chip select pin while the read/write sequence is fired, so the question is - is there some mode that will fire the chip select every n bytes? Or if not, what other fast ways are there to read data from SPI? Without reading multiple bytes in a single read/write sequence, it gets pretty slow - about 60kHz and I need more than that.