Configuring Master SPI Bus Speeds via PEx?

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring Master SPI Bus Speeds via PEx?

Jump to solution
454 Views
tharonhall
Contributor IV

I am using a K22F part and I need to configure the SPI bus in Master mode. In PEx under KDS, when I go to the spiCom1 component, and under the "Master mode" tab I can setup bus configurations. There is a "Clock rate" column that allows one to set up the clock rate. You can click on the value shown and get an button that takes you to a "Timing dialog - spiCom1/Clock rate" window. You can choose values based on 5 clock configurations. However, I don't know what is setting those clock configurations, and anything above 2.14MHz gives me an error, even though higher frequencies are listed.

I suspect I need to tweak the clock configurations, but I cannot locate where they are set. The modules references an fsl_clock_manager, but when I go there I don't see anything that actually sets up clock configurations.

Can anyone tell me where those are set up?

Thanks!

Tags (3)
0 Kudos
1 Solution
233 Views
tharonhall
Contributor IV

OK, for anyone that might read this one, I figured this out today:

I created my project from an example project for the K22F Freedom board. For whatever reason, the project came with several clock configurations. I switched the init clock config to the fast runtime configuration and away things went. That was all fine and good, but I still couldn't get the SPI bus above 2.1 MHz.

It turns out that even though I was only using the one clock configuration, the PEx SPI module, in its desire to be helpful, freaked out that there were clock configurations that would not work with the higher speeds if I chose to use it. Now, I disagree with that approach since I could have clock configurations that I might run that I would NOT use SPI on, and PEx was denying me the opportunity.

Rather than risk anything breaking by deleting any of the unused clock configurations, I simply set them all to high speed and viola, I can now clock at much higher frequencies. :smileyhappy:

Of course, none of this helps explain why my soft SPI code is SO unbelievably slow. :smileysad:

View solution in original post

0 Kudos
3 Replies
233 Views
dereksnell
NXP Employee
NXP Employee

Hi Tharon,

The clock configurations are part of the properties in the CPU component, and define the system clock frequencies used by the core and peripherals.  See screenshot below

Attached is a hands-on lab I created recently, dealing with the clock configurations within Processor Expert, and how it relates to peripheral setup. This lab was written for the IAR toolchain, but the Processor Expert steps are the same for any toolchain, including KDS.  So you can ignore the section on the IAR project.

Thanks


Clock Configs.jpg

234 Views
tharonhall
Contributor IV

OK, for anyone that might read this one, I figured this out today:

I created my project from an example project for the K22F Freedom board. For whatever reason, the project came with several clock configurations. I switched the init clock config to the fast runtime configuration and away things went. That was all fine and good, but I still couldn't get the SPI bus above 2.1 MHz.

It turns out that even though I was only using the one clock configuration, the PEx SPI module, in its desire to be helpful, freaked out that there were clock configurations that would not work with the higher speeds if I chose to use it. Now, I disagree with that approach since I could have clock configurations that I might run that I would NOT use SPI on, and PEx was denying me the opportunity.

Rather than risk anything breaking by deleting any of the unused clock configurations, I simply set them all to high speed and viola, I can now clock at much higher frequencies. :smileyhappy:

Of course, none of this helps explain why my soft SPI code is SO unbelievably slow. :smileysad:

0 Kudos
233 Views
tharonhall
Contributor IV

Thanks, Derek. This threw me as I would have expected the clocks in a clock peripheral of some kind, so thank you for pointing me in the right direction. I did some quick and dirty tweaks and couldn't get the speed shifted up but now that I know where to look I am sure I can unravel the mystery.

Thanks again!

0 Kudos