Error in configure_clock_rate with a non 13MHz osc

Technical questions regarding the XTC tools and programming with XMOS.
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Error in configure_clock_rate with a non 13MHz osc

Post by bearcat »

Have an L1-C5 I am using (500MHz). I am clocking this L1 at 12.288MHz. In the .xn file if I use 400MHz for the system frequency, everything is fine. If I put it at 500MHz, then two things happen.
During build:
1 - system frequency for node "Slave" could not be achived. Using 499998720Hz
2 - reference frequency for node "Slave" could not be achived. Using 99999744Hz

Ok, I guess. As close as it could get. (Going through the calc manually, it seems the above numbers are not correct either. The calculations give 497.66MHz, assuming it rounds down.)

The real problem is during debug, I get a runtime exception during this instruction:
configure_clock_rate(c_spi1, 100, spi_clock_div)
Disassembly:
0x00010448 <configure_clock_rate.coersed..f.7b0.7d.28ui.2cui.2cui.29+150>: ecallf (1r) r4


User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Post by paul »

Hi,

Some clock divider settings on configure clock rate are not valid and will result in an exception. From the library documentation in <install dir>/XMOS/DesktopTools/doc/libs/html/index.html - navigate to File List -> xs1.h

You will see the following
If the specified rate is not supported by the hardware, an exception is raised.
So, you can either find the closest one yourself - or if you are trusting then you can use the configure_clock_rate_at_least(...) or configure_clock_rate_at_most(...) functions to find the closest one above or below the required divide (respectively).

Hope that helps,
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
User avatar
Woody
XCore Addict
Posts: 165
Joined: Wed Feb 10, 2010 2:32 pm

Post by Woody »

@Bearcat

Did you manage to sort this problem out?
bearcat
Respected Member
Posts: 283
Joined: Fri Mar 19, 2010 4:49 am

Post by bearcat »

All is fine. Using a non 13MHz freq is ok. A few warning messages from the various tools is the only inconvinence.
I had not discovered the othe XS1 calls. Now I am quite famaliar with them.

Thanks for everyones help.