Page 1 of 1

Load external device before main program

Posted: Fri Aug 11, 2017 6:55 am
by jallard
I'd like to use the SPI port to program an external part from xCORE-200 before the main program starts.

Is there a way to hold-off other tiles and cores until a startup routine finishes? Or is there an existing startup routine that runs as a single threaded task, before other cores and tiles are started?

Re: Load external device before main program

Posted: Fri Sep 01, 2017 9:45 pm
by andrewxcav
A pretty typical way to run some initialization code for a single core would be as follows:

Code: Select all

some_task(){

    <initialization code goes here>

    while(1){
        <code you want to always run goes here>
    }

}
For your situation where you want other cores to wait on the initialization code you will need to signal them. This should happen automatically if they are waiting for some data that gets sent (via a channel, for instance) during the while(1) portion of your code.

There are many ways to do what you want. What makes the most sense will depend on your particular problem.

AN00218 : high res delay and sum is a good example of an application that has a few peripherals that are configured via i2c and a multi-core processing chain. (do a text search for "mabs_init_pll" for an example)

Re: Load external device before main program

Posted: Mon Sep 04, 2017 11:16 am
by johned
One feature of "par" is that it will wait for all functions to complete so you could do something like this :

void main () {
par {
iniit_fn1 () ;
iniit_fn2 () ;
}
par {
runtime_fn1 () ;
runtime_fn2 () ;
}
}

More details in the programming guide : https://www.xmos.com/download/private/X ... 28B%29.pdf

All the best,
John