I'm struggled with the behavior of an strobed buffered input. I would like to use an external parallel AD converter with enable/disable read signal. I have the following code:
Code: Select all
void InitHW(clock clk_adc,
clock clk_trig,
out port adc_clk_out,
in buffered port:16 adc_in,
in port adc_input_en_in,
out port adc_input_en_out,
out buffered port:1 ext_trig)
{
configure_clock_rate (clk_adc , 100 , DIVIDER); // setting of the clock block of the ADC port
configure_clock_rate (clk_trig , 100 , 1); // setting of the clock block for the trigger signal port
configure_port_clock_output (adc_clk_out , clk_adc); // clock output
//configure_in_port(adc_in, clk_adc); // buffered input port
configure_in_port_strobed_slave(adc_in, adc_input_en_in, clk_adc); // buffered !strobbed! input
configure_out_port(ext_trig, clk_trig, 0 ); // ext trig is sync to the adc clock
configure_out_port( adc_input_en_out, clk_trig,0);
set_port_sample_delay(adc_in); // ADC parallel input read is synced to the falling edge of the clock
start_clock(clk_adc);
start_clock(clk_trig);
}
Code: Select all
void AD92xxControlTask( in buffered port:16 adc_in, client interface AD92xx_DataIF_type adc_if)
{
unsigned int AdcDataBuffer[ COLLECTION_LENGTH ];
unsigned int* ptr = &AdcDataBuffer[0];
unsigned int index = 0;
printstrln("before the while");
while(1)
{
select{
case adc_in :> AdcDataBuffer[index] :
index++;
if( index == COLLECTION_LENGTH ){
printstrln("adc COLLECTION_LENGTH");
index = 0;
adc_if.PassPtr(ptr);
}
break;
}
}
}
Code: Select all
void task1( out buffered port:1 ext_trig,
out port adc_input_en_out,
server interface AD92xx_DataIF_type adc_if )
{
unsigned int adc_buff = 0;
unsigned int i=0;
adc_input_en_out <: 1; // enable adc
while(1)
{
select{
case adc_if.PassPtr( unsigned int* ptr) :
{
adc_input_en_out <: 0;
for(i=0;i<COLLECTION_LENGTH;i++){ adc_buff = *(ptr++); };
break;
}
}
}
}