XEF216-512 buffered input

Technical discussions around xCORE processors (e.g. General Purpose (L/G), xCORE-USB, xCORE-Analog, xCORE-XA).
swissembedded
Junior Member
Posts: 5
Joined: Tue Dec 31, 2019 9:54 am

XEF216-512 buffered input

Postby swissembedded » Tue Dec 31, 2019 6:28 pm

Hi,
I'm a bit desperate with the XMOS. Hope somebody could show me the end of the tunnel.

I basically have two tasks, one is sampling and integrating data (19.68MHz sampling rate, 12 bit values, 24 samples are summed up), the other is consuming it. Somehow that does not work and I can't debug it properly with XSCOPE.I fear that the interface call takes too long and that some samples are lost.

In the code below 16 sums are collected and send over the interface at once as an array of data.

The behaviour that I would expect is that I see the consuming task to increment the counter variable integrals_idx in steps of 16 and then overflows to 0 again. I would expect to get a new_integrals call every 19.68MHz / 24/ 16 = 51.25kHz.
In XScope I would expect to see a constantly increasing counter. But I only see connect is ok and triggering and no data at all. When I set breakpoints at the xscope _int statements, I can see that the xscope_int are called.

Code: Select all

interface bitstream_integral_interface {
    void new_integrals(uint32_t data[]);
};
The sampling task is the following

Code: Select all

#define MAXIMAL_INTEGRALS_LENGTH (1024)
#define INTEGRAL_LENGTH 16
#define SAMPLING_MASK 0x0FFF
#define SUM_SAMPLE\
 adc_data @ count++ :>  sample;\
 sum+=(sample&SAMPLING_MASK);
 
 void task_sampling(in port adc_dco, in buffered port:16 adc_data,
        clock clk_adc, client interface bitstream_integral_interface bitstream_integral,
                server interface init_interface init)
{
    /* ADC clock, ADC data ready on rising edge of DCO */
    configure_clock_src (clk_adc , adc_dco );
    configure_in_port_no_ready (adc_data , clk_adc );
    start_clock (clk_adc);

    set_core_high_priority_on();


    int count=0;
    uint16_t sample;
    uint32_t sum=0;

    uint32_t integrals[INTEGRAL_LENGTH];

    int pos=0;

    while(1)
    {
        sum=0;
        /* sample 24 x */
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        SUM_SAMPLE;
        integrals[pos++]=sum;
        pos&=(INTEGRAL_LENGTH-1);
        if(!pos)
        {
            bitstream_integral.new_integrals(integrals);
            xscope_int(XSCOPE_SAMPLING, count);
        }
    }
}
The consumer task is the following:

Code: Select all

void task_bitstream(server interface bitstream_integral_interface bitstream_integral,
        server interface control_bitstream_interface control_bitstream,
        client interface control_rx_interface control_rx)
{
    xscope_enable();
    uint32_t integrals[MAXIMAL_INTEGRALS_LENGTH];
    int integrals_idx=0;

    debug_printf("starting bitstream\n");

    while(1)
    {
        select {
        case bitstream_integral.new_integrals(uint32_t data[]):
            //memcpy(&integrals[integrals_idx], data, INTEGRAL_LENGTH*sizeof(uint32_t));
            integrals_idx+=INTEGRAL_LENGTH;
            integrals_idx&=(MAXIMAL_INTEGRALS_LENGTH-1);
            xscope_int(XSCOPE_BITSTREAM, integrals_idx);
            break;
            }
      }
}
Any hints what I'm doing wrong or pitfalls that I have to be aware of? Is it possible at all the that chip?

Best Dani
User avatar
mon2
XCore Legend
Posts: 1617
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Thu Jan 02, 2020 1:44 pm

Hi. I think the issue is that you have not read the port counter but rather forced the count=0 before starting your sampling.

Study figure 2 (page 5) of the attached document for example on how to read the port counter and how to process data relative to clock value forward in time. Then proceed to sample from this value, going forward.

Please post your update.
You do not have the required permissions to view the files attached to this post.
swissembedded
Junior Member
Posts: 5
Joined: Tue Dec 31, 2019 9:54 am

Postby swissembedded » Mon Jan 06, 2020 9:28 am

Hi mon2, thank you for your reply.
I did forget to add that line in the snipplet.
Actually I removed all @count statements and rewrote the task to handle :32 ports, that way I only had to read half the number of cycles (two samples at once) and I also moved to streaming channel, as the interface are too slow to handle it properly. As this is buffered input, it seems to work.
Is there any example for a simple buffered input from external clock without any enable signal?
Best Dani
User avatar
mon2
XCore Legend
Posts: 1617
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Wed Jan 08, 2020 5:55 am

See above PDF document and review page 9 & figure 5:

No Strobe Configure a port that needs no strobing

void configure_in_port_no_ready(void port p, clock clk);

Who is online

Users browsing this forum: No registered users and 0 guests