Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 7 months ago.
SPI Frequency
Working on the KL25z, I know there have been a few posts on this. I have an upper limit of 12MHz.
Question, as rule is the max SPI frequency 50% of the bus rate and when specifying the frequency does this need to be in some kind of binary multiple, i.e. something like 2048KHz rather than 2000KHz. Setting 12MHz gives me 12MHz, setting 11MHz I get 6MHz. Or is this just the way the KL25z works, 12 to 6 to 3...
1 Answer
9 years, 7 months ago.
They have an integer prescaler. So the bus frequency is 24MHz, and the highest it can do is divide that by 2 (one clock cycle high, one low: 12MHz). Next one is divide it by 4 (two clock cycles high, two cycles low: 6MHz), etc. I don't know if it really has an integer prescaler, then it can also do 3 cycles high, 3 low: 4MHz, or if it only has some powers of two it can divide by, in that case the next one is indeed 3MHz.
That you get 6MHz when you ask for 11MHz is likely because integer divisions are always rounded down.
Ran a few tests, 12+MHz gives 12MHz which is maximum for the KL25z and I assume anything else with a 24MHz bus clock. Checked the Teensy with the 48MHz bus clock, this is what I found.
24+ 24MHz teensy (12MHz KL25)
16 - 23.99 16MHz teensy (12MHz KL25)
12 - 15.99 12MHz teensy / KL25
6 - 11.99 6MHz
4 - 5.99 4MHz
3 - 3.99 3MHz
2 - 2.99 2MHz
1 - 1.99 1MHz
Pity we can't set the KL25 SPI to the bus frequency, my display will clock at 24MHz which means its only running at half its capable speed.
posted by 02 May 2016