How to run slow SPI

I'm using Ethernet Arduino and Arduino Uno, sometimes M0 Pro.

I want to intentionally run SPI at a slower clock speed. How to do this?

setClockDivider() appears deprecated, and doesn't appear to work for me.


SPISettings mySettting(speedMaximum, dataOrder, dataMode) only refers to max speed.

Reducing this figure has some effect, but not as I expected.

If there a right way to do this? Presumably I can access the processor SPI clock divider directly?

An update.

Using setClockDivider() after SPISettings mySettting(speedMaximum, dataOrder, dataMode) does appear to work.

It appears my Uno defaults to setClockDivider(16) for 1MHz SPI, and the slowest I can achieve is 125KHz with setClockDivider(128)

Is this correct?

See "Table 23-5. Relationship between SCK and Oscillator Frequency" in the ATmega328P datasheet.

The minimum clock divider is 2, so the maximum SCK frequency is 8 MHz.

Judging by this I should be able to set the SPI clock to speeds between 8MHz and 125KHz in binary steps.

As someone who knows microcontrollers and 'C' better than I know Arduino, am I correct in thinking I can drive this register in the same way as I would in an ordinary 'C' environment?

You could. But that's exactly what setClockDivider does:
See source

By the way, if you want really slow SPI, you can bitbang it, take a look at the source for shiftOut, for example.