Performing I/O on Specific Clock Edges on high speed adc? Topic is solved

If you have a simple question and just want an answer.
User avatar
Minamisava
Member
Posts: 13
Joined: Thu Jul 03, 2014 3:48 pm

Performing I/O on Specific Clock Edges on high speed adc?

Post by Minamisava »

I'm trying to understand and adapt the high speed adc library AN01021.
It creates a unsigned ts and then uses it to trigger it for the high speed adc interface.
Where is the update rate of this communication?
And where is the initialization of the ts variable?
For timers we use "t :> time;" to synch up values.

What am I missing here?

I read XC Clocked Input and Output but didn't understand the use of it.
https://www.xmos.com/published/xc-clock ... and-output


Code: Select all

 unsigned data_1,data_2,ts;
 //reference clock is set to 50MHz
  configure_clock_rate(clk,100,2); 
  configure_port_clock_output(p_clk_out, clk);
  //Configuring all the ports synchronous to reference clock
  configure_out_port(p_convsr, clk, 0);
  configure_out_port(p_sdi, clk, 0);
  configure_out_port(p_rd, clk, 0);
  configure_in_port(p_sdoa, clk);
  configure_in_port(p_sdob, clk);

  p_rd<:0x0000000;
  p_convsr<:0x00000000;
  p_sdi<:0x00000000;
  set_port_shift_count(p_sdoa,16);
  set_port_shift_count(p_sdoa,16);
  start_clock(clk);
  p_cs<:0;
  while(1)
  {
      p_rd @ (ts+5)<:0x00010001 ;
      p_convsr @ (ts+5) <:0x00010001;
      //write LSB first for two channels at a time
      p_sdi @ (ts+7) <:0x05555550;
      //Read two channels at a time. As we are usign 32 bit buffered ports
      p_sdoa:> data_1;
      p_sdob:> data_2 @ ts;
      //Send the data read to the application using channels
      c<:data_1;
      c<:data_2;
  }
}


View Solution
Choughtosh
Member++
Posts: 22
Joined: Thu Apr 10, 2014 9:39 am

Post by Choughtosh »

Hello,

I think you've spotted a bug in the code for this application note - I'll submit a bug report.

You are right, ts is not initialised before it's used for the first time in :

p_rd @ (ts+5)<:0x00010001 ;

However, when the code reaches this line :

p_sdob:> data_2 @ ts;

ts will be initialised to to the time at which the data was received and the loop will execute correctly from there.

The programming guide discusses this functionality in section 6.8.

The update rate is derived from the clk output which in the application note is sourced from an external source.

Rob
User avatar
Minamisava
Member
Posts: 13
Joined: Thu Jul 03, 2014 3:48 pm

Post by Minamisava »

Thank you for the answer!
Just understood it!
But there is still a problem (at least in my simulation)
Choughtosh wrote: However, when the code reaches this line :

p_sdob:> data_2 @ ts;

ts will be initialised to to the time at which the data was received and the loop will execute correctly from there.

The programming guide discusses this functionality in section 6.8.

The update rate is derived from the clk output which in the application note is sourced from an external source.

Rob
On this part ts is updated, but the delays used aren't enough to make the continous reads.
It works with a ts+=1000; but that is still far from a continous read. I'll work on it and open a thread in case I can't make it.

Thanks for the help!