clock based pulse train

Technical questions regarding the XTC tools and programming with XMOS.
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

clock based pulse train

Post by cicga »

Hi all,

is it possible to create a clock based pulse train of specific length?
lets say we r using clock block, link it to out pin so we have clock signal going out,
but how to send only 10 clock pulses out?

thanks


User avatar
Lele
Active Member
Posts: 52
Joined: Mon Oct 31, 2011 4:08 pm

Post by Lele »

Need to use buffered clocked port:

Code: Select all

#include <platform.h>

clock ClkBlk = XS1_CLKBLK_1;
out buffered port:32 Clk = XS1_PORT_1M;

#define CLK_PATTERN 0x55555555

int main()
{
  // configure ports and clock blocks
  configure_clock_ref(ClkBlk, 64); // set clock block frequency
  configure_out_port(Clk, ClkBlk, 0); // set source clock for port and initial value
  start_clock(ClkBlk); // start the clock block
  partout(Clk, 2*10, CLK_PATTERN); // load 10 clocks
  sync(Clk); // wait end of clock burst
  return 0;
}
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

Post by cicga »

Lele,
thanks for code -unfortunatly the idea was not to be limited by bufferd port size - in your sample code
train will be less or equal to the 32 pulses. I want ot create 400 pulses block for instance.

best
User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Well one way you can try going at it is to calculate how long its going to take the clock block to make that many pulses and enable it for only that amount of time.

So you could get a timestamp from a timer the next line after enabling the timer and wait for the time to pass and disable it right after. It might be problematic if your clocks are very fast tho.
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

Post by cicga »

hi berni,

I found too that this is the way to go - i just put stamp after clock start and at some point clock stop. with some adjustment his is wokring very good.

thanks