Generating a clock signal on xCore-200

Technical questions regarding the XTC tools and programming with XMOS.
manni
Newbie
Posts: 1
Joined: Sun Oct 26, 2025 1:30 am

Generating a clock signal on xCore-200

Post by manni »

Hi,

I just started learning programming in xC by reading the language reference https://www.xmos.com/download/XMOS-Prog ... 8E%29.pdf/ and following along with a xCore-200 eXplorer board and XTC 15.3.1 and I am stuck trying to generate a clock signal.
I followed the example (page 66), but when running the code and monitoring the p_clock_out pin with a logic analyzer, the pin just stays low.
Toggling the pin manually, however, works as expected, so the error must be with the clock itself.

Code: Select all

#include <platform.h>
#include <xs1.h>

on tile[0]: out port p_out = XS1_PORT_8A;
on tile[0]: port p_clock_out = XS1_PORT_1A;
on tile[0]: clock clk = XS1_CLKBLK_1;

int main()
{
  configure_clock_rate(clk, 100, 8);  // 100/8 = 12.5 MHz
  configure_out_port(p_out, clk, 0);  // p_out clocked by clock clk with initial value 0
  configure_port_clock_output(p_clock_out, clk);  // causes clock signal to be driven in the pin connected to port p_clock_out
  start_clock(clk);

  for (int i=0; i<5; i++)
  {
    p_out <: i;
  }

  return 0;
}
Any help would be greatly appreciated.
Thanks!
lmariotti
Active Member
Posts: 45
Joined: Mon Nov 21, 2022 5:38 pm

Post by lmariotti »

Hi manni,

first of all there is a new revision of the guide you mentioned: https://www.xmos.com/download/XMOS-Prog ... n)(F).pdf/
Anyway the "Generating a clock signal" paragraph it's exactly the same

The main difference that I see between your code and the example in the programming guide is that the clock port is not marked as "out":

Code: Select all

on tile[0]: port p_clock_out = XS1_PORT_1A;  // <--- Your code
out port p_clock_out = XS1_PORT_1A;  // <--- XMOS example
Not sure if this can fix it but it's worth to give it a try

Regards
Joe
Verified
XCore Addict
Posts: 136
Joined: Sun Dec 13, 2009 1:12 am

Post by Joe »

Hi, good to see you learning xmos tech!

Your program works
Capture.jpg
I'd suggest using xsim to simulate your program as a good way to learn programming with xmos. You can then also see more detail of what's happening with the clock blocks/ports/instruction etc.

If you build your program and then use the command: xsim clock.xe --vcd-tracing "-o trace.vcd -tile tile[0] -ports-detailed -clock-blocks -cycles -instructions"

This will produce a vcd file which you can open with the open source viewer gtkwave to see the above output (and add the relevant signals to the view window).

You don't see a clock output because the program completes and terminates which stops the clock. If you want to see it persist for all time, add a while(1) at the end of your program.

Cheers,
Joe
You do not have the required permissions to view the files attached to this post.
XMOS hardware grey beard.