# SPI clock speed for ARM (Itsybitsy M4) 'explained'

#1

Hi David ,

I’ve taken some time to test how the SPI clock speed behaves using the speed option in (with-spi (str clock-divider).
These are my conclusions based on my 100Mhz digital scope.
First of all , it depends on the spi setting in the arduino IDE, under Tools you have an option for setting the highest SPI speed , being 24MHz (standard) or 50MHz or CPU/2 which is 60Mhz on 120Mhz cpu clock.
Then the next thing to consider is that all ODD numbers can not be used. So you can only divide by 2,4 6,8,10 and so on with 254 being the largest divider.
The clock for max SPI set in arduino must also be doubled for the calculation.
Example:
Max SPI speed set in arduino = 24MHz
I choose a divider of 10
This gives 24M*2 = 48M , divided by 10 = 4.8Mhz
If you divide by 11 , the result stays the same
If you divide by 12 , the result will be 48M/12 =4MHz.
A divider of 0 , 1 , 2 or 3 will give the max SPI speed *2 , divided by 2 , being 24Mhz in this case

Hoping this can help for the ulisp reference on the website , and hoping it also can help other ‘ulispers’ using ARM boards.

Kind regards ,

Ronny Suy

#2

Hi Ronny,

Thanks for this. Are you happy with the way in which ARM uLisp 2.7 handles with-spi?

Regards, David

#3

Sure I am !
I just wanted to let you know how it works now.
For me its ok.
I would be happy if you put it in the reference.

Kind regards
Ronny

#4

David ,

I will also test this on an ESP32 board , but I have to order one.
So this can take some time.

Regards
Ronny

#5

Hi Ronny,

I’m trying to understand SPI on the ARM platforms with the help of your research.

You say:

First of all , it depends on the spi setting in the arduino IDE, under Tools you have an option for setting the highest SPI speed , being 24MHz (standard) or 50MHz or CPU/2 which is 60Mhz on 120Mhz cpu clock.

I’ve just updated to “Adafruit SAMD Boards” 1.5.0, and selecting the “Adafruit ItsyBitsy M4 (SAMD51)” board option on my Mac the option I see for setting the SPI speed is “Max QSPI”. Is this what you’re referring to?

What is the SPI speed if you don’t change anything, or set a divider in uLisp? Is it 24MHz?

What does the divider set in uLisp divide? The default SPI speed (24MHz) times 2? So a divider of 2 gives you the same as specifying no divider?

I see that for the ItsyBitsy M4 you can now increase the clock speed. Does the SPI speed change depending on the clock speed?

Do you know if the behaviour is the same for all ARM platforms?

Thanks!
David

#6

On 6/11/19 12:12 PM, David Johnson-Davies wrote:

johnsondavies
June 11

Hi Ronny,

I’m trying to understand SPI on the ARM platforms with the help of your research.

You say:

First of all , it depends on the spi setting in the arduino IDE, under Tools you have an option for setting the highest SPI speed , being 24MHz (standard) or 50MHz or CPU/2 which is 60Mhz on 120Mhz cpu clock.

I’ve just updated to “Adafruit SAMD Boards” 1.5.0, and selecting the “Adafruit ItsyBitsy M4 (SAMD51)” board option on my Mac the option I see for setting the SPI speed is “Max QSPI”. Is this what you’re referring to?

No it wasn’t that. I see indeed that this option is removed on version 1.5.0.
I’ve downgraded to 1.4.1 and there you have his option.
I haven’t got a clue why they removed it.
I don’t think that the QSPI is involved , but I will test it , and see what formula comes out.

What is the SPI speed if you don’t change anything, or set a divider in uLisp? Is it 24MHz?

I have to test this again on the new driver. Probably 24Mhz.

What does the divider set in uLisp divide? The default SPI speed (24MHz) times 2? So a divider of 2 gives you the same as specifying no divider?

Yes it looked like it , again I will redo the test on the new driver

I see that for the ItsyBitsy M4 you can now increase the clock speed. Does the SPI speed change depending on the clock speed?

I didn’t test this , but I will do now , but my guess is it will increase.

Do you know if the behaviour is the same for all ARM platforms?

Thats a hard one , I have a MKRzero if I’m correct , I will test it as well.

Conclusion :
It’s a bit annoying that they changed the driver so radically.
I will test as much as possible in the next days or so , and let you know the results.

Ronny.

Thanks!
David

#7

Thanks for trying to get this sorted out!