There is a FRAME line which goes low when the device starts transmitting data, and then does high after 4 clock cycles. The data sent is 32 bits and clocked by LCLKIN. In this example data are transmitted on SD01 and SD03, one of them is inverted, presumably due to a wiring error.
LCLKIN is generated on the XMOS and I am using it to clock in the data into a buffer.
All this basically works. Evidenced by SD03 being echoed in a lagged form onto p_debug2 when p_debug2 <: sd03; is uncommented.
My problem is this... I have a simple interface to get the data out of the task, it does not yet have a client [hence gives me a warning in main]. If I uncomment the notifier i_tdc.data_ready(); or the get_data case then the whole thing stops working. This implies that there is significant overhead in the notification call to data_ready(), which I thought was supposed to be a very efficient means of pinging a outside tasks. Also that there is an overhead in having a second case statement in my select, even when that case is never hit.
Am I missing something?
Is there a better method for getting the data out of this task in a timely manner that does not cease up this task?
Code: Select all
typedef interface tdc_if
[[clears_notification]] int get_data();
[[notification]] slave void data_ready();
on tile : in buffered port:4 p_comms0 = XS1_PORT_4C;
#define FRAME1 (comms0 & 0x01)
#define SD03 (comms0 & 0x04)
on tile : out port p_debug = XS1_PORT_1E;
on tile : out port p_debug2 = XS1_PORT_1F;
#define REF_WIDTH (12)
#define STOP_WIDTH (20)
#define COMMS_WIDTH (REF_WIDTH + STOP_WIDTH)
void tdc_task(server tdc_if i_tdc,
client spi_master_async_if spi,
out port p_refclk, clock clk_refclk,
out port p_lclkin, clock clk_lclkin,
in port p_lclkout)
configure_clock_rate (clk_lclkin , 100 , 10);
configure_port_clock_output (p_lclkin , clk_lclkin);
int comms_index = -1;
int count = 100;
case p_comms0 :> comms0:
sd03 = (SD03 ? 1 : 0);
p_debug2 <: 1;
// p_debug2 <: sd03;
if (comms_index == -1) // Waiting for frame
if (FRAME1 == 0)
p_debug <: 1;
data = comms_input;
comms_input = (sd03 ? (1<<(COMMS_WIDTH-1)) : 0);
comms_index = COMMS_WIDTH-2;
p_debug <: 0;
comms_input |= (sd03 ? (1<<comms_index) : 0);
p_debug2 <: 0;
/* case i_tdc.get_data() -> int x:
x = data;