Changing SPI0 Clock Rate

I am able to get SPI0 working on the BeagleBone Black by using only config-pin commands:

config-pin P9_17 spi config-pin P9_18 spi config-pin P9_21 spi config-pin P9_22 spi

Then writing to /dev/spidev1.0 causes data to come out the pins P9_18 (data) and P9_22 (clock).

Note that searching for how to enable SPI on the BeagleBone returns tutorials that all involve “device trees” or a “cape manager”. None of this was necessary for me to get SPI working. I assume they used to be required at some point in the past. I simply set the pins to SPI and it works.

Now I’d like to change some SPI settings, like the clock rate. It seems the hardware has a frequency divider that can be set to change the SPI clock rate. What is the clock rate by default? How can I change it? Ideally I’d like to change it by command with the BeagleBone running, hopefully no recompiling or rebooting required every time I make a change.

How should I go about this?

Note that I’m running the image “bone-debian-8.6-iot-armhf-2016-10-16-4gb.img.xz” found here:

https://rcn-ee.com/rootfs/bb.org/testing/2016-10-16/iot/

I am able to get *SPI0 *working on the BeagleBone Black by using only
*config-pin* commands:

config-pin P9_17 spi
config-pin P9_18 spi
config-pin P9_21 spi
config-pin P9_22 spi

Then writing to */dev/spidev1.0 *causes data to come out the pins P9_18
(data) and P9_22 (clock).

Note that searching for how to enable SPI on the BeagleBone returns
tutorials that all involve *"device trees"* or a *"cape manager"*. None
of this was necessary for me to get SPI working. I assume they used to be
required at some point in the past. I simply set the pins to SPI and it
works.

Actually, device tree file(s) were involved, you just did not realize it.
By using config-pin, you're using one of the universal IO device tree
overlays.

Now I'd like to change some SPI settings, like the clock rate. It seems
the hardware has a frequency divider that can be set to change the SPI
clock rate. What is the clock rate by default? How can I change it?
Ideally I'd like to change it by command with the BeagleBone running,
hopefully no recompiling or rebooting required every time I make a change.

How should I go about this?

Note that I'm running the image
*"bone-debian-8.6-iot-armhf-2016-10-16-4gb.img.xz"* found here:

<http://goog_839341451>
https://rcn-ee.com/rootfs/bb.org/testing/2016-10-16/iot/

So, I do not really know much about the SPI hardware per se. However, I do
know that if you check an overlay file for SPI, say :
https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-SPIDEV0-00A0.dts#L63
Look at the highlighted line. If you're wanting to raise the frequency,
there is is. But except if you're wanting to use a universal IO overlay,
which I completely understand. You'll have to edit the file that is
preloaded at boot, *or* the overlay file that is loaded when you invoke the
config-pin script.

As far as the clock, and divider . . . Well as I recall the clock is 48Mhz,
which means if the frequency is 16Mhz, the divider is 3x. Anyway, as I said
I really do not know the SPI hardware well. SO take what I say with a grain
of salt. As what I'm saying concerning the clock and divider is going by
memory. Where I've never used the hardware, and my memory is sometimes less
than perfect.

RIcky:
Why are you needing to change the clock rate?

–Prof. Yoder