joan2937 / pigpio

pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).
The Unlicense
1.46k stars 410 forks source link

Scheduling repetitive SPI writes #603

Open davthomaspilot opened 8 months ago

davthomaspilot commented 8 months ago

I'm considering implementing a frequency scan algorithm that requires precise control of when SPI writes to change frequencies are done.

If the frequency change is not done quickly enough, a message on the new frequency will be missed. So, rather than issuing the SPI commands from code, they are generated from "waves"

Five SPI writes are required to change the receive frequency. I'd like those writes to occur repetitively, without requiring processor intervention. The desired result would have the radio hang frequency every X milliseconds (X = somewhere between 5 and 10).

It looks straight forward, but maybe there are issues I'm missing?

Also, the card I'm working with is already wired to the hardware SPI pins. Can I just do a `sudo dtparam spi=off and use BB SPI on the hardware SPI pins?

`

guymcswain commented 8 months ago

Can I just do a `sudo dtparam spi=off and use BB SPI on the hardware SPI pins?

Yes or better, turn it off by editing /boot/config.txt

davthomaspilot commented 8 months ago

Yes, but I thought I would do it dynamically, at least until I've sure the BB version is working. (Currently, the code is using the hardware SPI and I don't want to break that.

Also, I might want to use the hardware UART to do all the register writes required to initially configure the chip. Then, disable the hardware UART and start the periodic, BB SPI writes

If I'm only doing SPI writes, is there a reason the baud can't be higher than 250K. Maybe I have to change the default sampling rate to go higher?

guymcswain commented 8 months ago

For waves (output) the maximum frequency output is 500KHz. Sample rate does not affect it.