Is this OK in USB core

If you have a simple question and just want an answer.
guodian
Member++
Posts: 21
Joined: Sat Nov 12, 2016 10:48 am

Is this OK in USB core

Post by guodian »

Hi,

My design is referenced by xCORE-200 Multichannel Audio Platform. Now I use a pin on tile 1 for an output. I know the XUD module is on tile 1 and no more than six cores shall execute on it. So I add my code like this in main.xc file in usb_audio_core() function

Code: Select all

        /* USB Packet buffering Core */
        {
            unsigned x;
            thread_speed();


            //my code
            other_chip_conf();


            /* Uses same clock-block as I2S */
            asm("ldw %0, dp[clk_audio_mclk]":"=r"(x));
            asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));

            //:buffer
            buffer(....omit....);
            //:
        }
The other_chip_conf() function is simple. It just contains an output statement

Code: Select all

void other_chip_conf(void)
{
    /*Right Channel Digital High-Pass Filter Configuration*/
    set_gpio_bit(pGpio11a, PT_GPIO_HPFDR, HPFD_ENABLE);
}
The application uses 4 cores on tile 1 now. For the function is too simple, I don't want to create a new task on tile 1 in order to reduce overhead and guarantee MIPS. Am I right?


henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Hi guodian,

I think you are on the right lines - let me explain a bit first.

There are two ways to extend code. One is to add tasks on "logical cores", the other is to modify existing tasks. The first one looks like this

Code: Select all

main() {
  par {
    on tile[0]: A();
    on tile[0]: B();
    on tile[0]: X();  // adding this line has created an extra task to be executed concurrently on tile[0]
    on tile[1]: C();
    on tile[1]: D();
  }
}
The second one looks like this:

Code: Select all

A() {
  while(1) {
    R();
    S();
    Y();    // Adding this line adds some activity inside task A
    T();
  }
}
The latter will slow down task A() between S() and T(). This is ok if there is enough time between S() and T() to complete Y().

The former may slow down all tasks on that tile. In general, each task gets 1/N of the tile performance (when there is N tasks) but a task can never get more of 1/5th of the tile performance.

So yes - if there is a tile that runs 4 tasks, then you can always add a task without it slowing down any of the other tasks. But, if you add a statement inside the code of that task, then it will slow down that task.

Cheers,
Henk
guodian
Member++
Posts: 21
Joined: Sat Nov 12, 2016 10:48 am

Post by guodian »

Thanks henk,

I think my method may seem like the second way you said. The codes involved in this brace are all run in the same core(USB buffer core), and the loop is involved in buffer() function. So, my code should not slow down the task.

Let me add. What's the function of thread_speed(). Can I add my code under it?
henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

I see - yes, with the while(1) inside the buffer() function this call will make no difference. I don't know what thread_speed() does, it probably alters the thread-state a bit; not something that takes any time.

So - yes, that is a safe place to put a call.

Since the code is outside the while(1) loop it is only called once when the device starts; is that ok?

Cheers,
Henk