SPI speed set up

Technical questions regarding the XTC tools and programming with XMOS.
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

SPI speed set up

Post by mhanuel »

Dear all,

I want to know if the SPI_CLOCK_DIV is the only thing you can change for setting up the SPI speed. If that's correct, you only can go from 50 MHz to 25 MHz when using a value of 2 and 1 respectively for SPI_CLOCK_DIV.

Is there any way I can get 40 MHz for example?

Comments will be appreciated,

Manuel


User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

The maximum you can get is 50MHZ. But, the frequency is calculated by the formula 100 MHz/2*n. So, If you want to get the frequencies like 40MHz, you need to have an external clock.

Thanks,
Sethu.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

You can change the reference clock to be something else
than 100MHz. You'll have to make sure the other things
that use it can handle the change.
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

Post by mhanuel »

Thank you very much for your comments ,

I am using startKIT board.
I was trying to change the reference clock using the XN file but it always gave me a warning about not possible to set the reference clock to XXX using a system clock of XXX.

If I choose a system clock of 500MHz and ref clock of 125MHz, it build ok, just a warning about node 0 having a different ref clock from 100MHz, but when running the code an exception raise on the console.

Can you give an advice about how to accomplish the clock modification?

Thank you in advance,
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

You'll have to show the actual error message, there aren't
too many clairvoyant people here.

Maybe my warning above wasn't clear: the reference clock
is used in a few places in hardware, and in many places in
code; and some of those places assume it always runs at
100MHz. Many things have never been tested with a different
clock.
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

Post by mhanuel »

Dear sethu,

Thank you for your comments,

Attached is the compilation warning.

It compiles but when I run the following message stop execution

xrun: Program received signal ET_ECALL, Application exception.
0x000116d2 in configure_clock_rate ()

I realize that changing PLL setting on this MCU is like black magic using xTIMEcomposer studio.

Best,
You do not have the required permissions to view the files attached to this post.
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

The configure_clock_rate() function will trap if it can't meet the clock frequency exactly, so I suspect that is why you see an exception. If you just want the closest clock frequency you can use configure_clock_rate_at_least() or configure_clock_rate_at_most() functions instead.