You might want to look at this recent thread (

https://forum.pjrc.com/threads/72003...eedup-question), but I've been curious about this because it seems to be a common question, so I'll try to answer. The SPI clock frequency for T4 is set in function beginTransaction() of file SPI.h. By adding a printf(), here's what I see. Hopefully others with more experience will comment/correct as necessary.

- base clock frequency is 240 MHz (there are multiple possible clock sources, but the one being used is 240 MHz)

- beginTransaction() computes a clock divisor() to get as close to requested frequency as possible without going over

- for the default SPI clock frequency of 4 MHz, the computed divisor is (58+2)=60

- the table below shows the actual SCK frequency for requested frequencies from 1-120 MHz

- at high frequencies, the divisor gets small, so the actual frequency can diverge from requested

- above 20 MHz, you can get exactly 20, 24, 30, 40, 48, 60, 80, 120, and a few in between

Code:

_clock = 1000000 clkhz = 240000000 div = 238+2=240 actual = 1000000
_clock = 2000000 clkhz = 240000000 div = 118+2=120 actual = 2000000
_clock = 3000000 clkhz = 240000000 div = 78+2= 80 actual = 3000000
_clock = 4000000 clkhz = 240000000 div = 58+2= 60 actual = 4000000
_clock = 5000000 clkhz = 240000000 div = 46+2= 48 actual = 5000000
_clock = 6000000 clkhz = 240000000 div = 38+2= 40 actual = 6000000
_clock = 7000000 clkhz = 240000000 div = 33+2= 35 actual = 6857142
_clock = 8000000 clkhz = 240000000 div = 28+2= 30 actual = 8000000
_clock = 9000000 clkhz = 240000000 div = 25+2= 27 actual = 8888888
_clock = 10000000 clkhz = 240000000 div = 22+2= 24 actual = 10000000
_clock = 11000000 clkhz = 240000000 div = 20+2= 22 actual = 10909090
_clock = 12000000 clkhz = 240000000 div = 18+2= 20 actual = 12000000
_clock = 13000000 clkhz = 240000000 div = 17+2= 19 actual = 12631578
_clock = 14000000 clkhz = 240000000 div = 16+2= 18 actual = 13333333
_clock = 15000000 clkhz = 240000000 div = 14+2= 16 actual = 15000000
_clock = 16000000 clkhz = 240000000 div = 13+2= 15 actual = 16000000
_clock = 18000000 clkhz = 240000000 div = 12+2= 14 actual = 17142857
_clock = 19000000 clkhz = 240000000 div = 11+2= 13 actual = 18461538
_clock = 20000000 clkhz = 240000000 div = 10+2= 12 actual = 20000000
_clock = 22000000 clkhz = 240000000 div = 9+2= 11 actual = 21818181
_clock = 24000000 clkhz = 240000000 div = 8+2= 10 actual = 24000000
_clock = 27000000 clkhz = 240000000 div = 7+2= 9 actual = 26666666
_clock = 30000000 clkhz = 240000000 div = 6+2= 8 actual = 30000000
_clock = 35000000 clkhz = 240000000 div = 5+2= 7 actual = 34285714
_clock = 40000000 clkhz = 240000000 div = 4+2= 6 actual = 40000000
_clock = 48000000 clkhz = 240000000 div = 3+2= 5 actual = 48000000
_clock = 60000000 clkhz = 240000000 div = 2+2= 4 actual = 60000000
_clock = 80000000 clkhz = 240000000 div = 1+2= 3 actual = 80000000
_clock = 120000000 clkhz = 240000000 div = 0+2= 2 actual = 120000000