Skip to main content

Timeline for Fast SPI reading

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Jan 31, 2022 at 18:02 comment added joan Your question says the Python is reading 44100 samples in 2 seconds. That is 22k. More than the 15k from your C.
Jan 31, 2022 at 16:55 comment added Pygmalion I am using RPi4 and sampling is faster with C. I am using spi.delay_usecs = 0; spi.speed_hz = frequency; spi.bits_per_word = 8;
Jan 31, 2022 at 16:49 comment added joan You are doing something wrong if you are getting slower rates in C compared to Python. Have you set the SPI bit rate in your C code?
Jan 31, 2022 at 16:33 comment added joan Use pigpio. Use a faster Pi (you appear to be using an old one).
Jan 31, 2022 at 16:15 comment added Pygmalion With a simple C script (ioctl(fd_spi, SPI_IOC_MESSAGE(1), &spi); spi.rx_buf = spi.rx_buf + 2;) I could get about 15k sampling. Unfortunately sampling is not very consistent, which means that FFT of the sound is rather noisy. Any ideas for improvement?
Jan 31, 2022 at 13:34 comment added Pygmalion @Abel I intend to use ctypes since I already have experience with that.
Jan 31, 2022 at 12:39 comment added Abel integrate top level python calls into low level c calls with cython. don't do a big for loop in python- instead loop in c but tell c the number to loop via python.
Jan 31, 2022 at 9:55 vote accept Pygmalion
Jan 31, 2022 at 9:55
Jan 30, 2022 at 22:37 history answered joan CC BY-SA 4.0