Reply by Andrey Krokhin November 16, 20102010-11-16
Thanks for your suggestions. Due to the complexities in passing
arguments to Clock functions, we decided to use, for now, global
variables and initialization at the point of declaration.

Regards,
Andrey
On 11/12/2010 8:15 PM, Richard Williams wrote:
>
> Andrey,
>
> The fact that the location/address of the 2 variables can change is not a
> problem.
>
> You have to re-compile/re-link the software after any change, so the
> actual
> address is always available.
>
> Yes, the variables will be 'global'. That does not mean that every
> file/task
> has to be told about them via an 'extern' statement. Only two files
> need to
> know about them. The task that sets the values and the clock interrupt
> handler
> that you are writing.
>
> If you are worried about their visibility then:
> have a task contain the variables. And contain two functions.
> One function to set the variables and one function to return the
> values from
> those variables.
> Then the clock interrupt handler calls the function that returns the
> values.
>
> This is just like many interrupt handlers that need to access some data.
>
> You really do need to have the function that sets the variables make
> use of some
> methodology to inhibit the clock function while the variables are
> being set,
> such that the clock interrupt is not trying to read the variables
> while they are
> being set.
>
> R. Williams
>
> ---------- Original Message -----------
> From: Andrey Krokhin > >
> To: Richard Williams > >
> Cc: C6x >
> Sent: Fri, 12 Nov 2010 15:27:04 -0600
> Subject: Re: [c6x] Passing parameters to a Clock function in SYS/BIOS
>
> > Hello Richard,
> >
> > Thanks for your advice. My understanding is that you suggest to define
> > variables at some fixed memory addresses. For a SYS/BIOS project, I
> > couldn't implement this, please see this thread
> >
> > http://e2e.ti.com/support/dsp/c6000_multi-
> core_dsps/f/439/p/70452/258195.aspx#258195
> >
> > The second problem is, even if I worked to implement the mutex and
> > checks you described, it seems that the solution would be equivalent
> > to using global variables, which are placed in some defined locations
> > in memory (LL2 and SL2 RAM). No stack variables would be possible.
> >
> > Furthermore, if I could define custom memory locations in SYS/BIOS
> > (see the thread above), the memory layout of these global variables
> > would have to change when the number of variables or their size
> > changes. For example, if you have a 100-int array, and then changed it
> > 200-int, all memory locations that follow these arrays would have to
> > be shifted.
> >
> > So, from your reply, I guess there is no simple solution to it, and
> > "Clock" (I mean ti.sysbios.knl.Clock module) is primarily intended for
> > arg-less tasks.
> >
> > Andrey
> >
> > On 11/11/2010 5:21 PM, Richard Williams wrote:
> > >
> > > Andrey,
> > >
> > > There are a couple of ways to go about this.
> > >
> > > Here is my suggestion:
> > > Have the clock function load values from known locations in RAM.
> > > Use a mutex (or similar) to kill interrupts (or at least the clock
> > > interrupt)
> > > while the main program is updating those known locations in RAM.
> > >
> > > *I* would also have the clock function clear those same variables to
> > > NULL, 0
> > > during its' execution.
> > > Then when reading those known locations, have a 'safety' check that
> > > the known
> > > locations actually contain fresh data before using the data.
> > > I.E contain something besides NULL, 0.
> > >
> > > BTW:
> > > when you say 'clock' do you actually mean the RTC or one of the
> timers?
> > >
> > > R. Williams
> > >
> > > ---------- Original Message -----------
> > > From: Andrey Krokhin >
> > > >
> > > To: C6x
> >
> > > Sent: Thu, 11 Nov 2010 10:19:33 -0600
> > > Subject: [c6x] Passing parameters to a Clock function in SYS/BIOS
> > >
> > > > Hello,
> > > >
> > > > I am trying to build a program that uses SYS/BIOS (aka BIOS 6)
> with CCS
> > > > 4.2. The BIOS "Clock" module can be set up to run a function either
> > > > periodically or only once ("one-shot"). In my case, I need to run it
> > > > only once. Setting up and initializing the clock is not a problem:
> > > >
> > > > Clock_Handle clk;
> > > >
> > > > Clock_Params clkParams;
> > > >
> > > > Clock_Params_init(&clkParams);
> > > >
> > > > clkParams.period = 0;
> > > >
> > > > clkParams.startFlag = FALSE;
> > > >
> > > > clk = Clock_create(myFunc, 1, &clkParams, NULL);
> > > >
> > > > Clock_start(clk);
> > > >
> > > > In Clock_create, I am setting up the clock to execute "myFunc".
> What I
> > > > don't know how to do is pass parameters into myFunc. From BIOS
> > > > documentation, the only way I saw is to define the optional clock
> > > argument:
> > > >
> > > > clkParams.arg = (UArg)0x1234; /* set up a flag for the clock */
> > > >
> > > > However, that's just a single 32-bit value. What I need is to pass
> > > > arbitrary parameters, which might include different primitive types,
> > > > pointers, and structures, into myFunc. Suppose myFunc is defined as:
> > > >
> > > > void myFunc(int* x, size_t x_len);
> > > >
> > > > Is there a way to do it? It seems that not being able to pass
> > > > parameters to functions, either periodic or one-shot, would be a
> > > > significant restriction. I am sure it can be done, I just lack
> > > > knowledge on SYS/BIOS.
> > > >
> > > > Thanks,
> > > > Andrey
> > > ------- End of Original Message -------
> > >
> > >
> >
> >
> >
> >
> >
> > _____________________________________
> >
> >
> >
> >

_____________________________________
Reply by Andrew Elder November 13, 20102010-11-13
Another option is to use a DSP/ BIOS mailbox to transfer arguments. One thread would post formatted args and the clk function would pull them off. You would have to decide the passing convention to use. ie post pointers or make a copy of the data.

Andrew
Reply by Richard Williams November 12, 20102010-11-12
Andrey,

The fact that the location/address of the 2 variables can change is not a
problem.

You have to re-compile/re-link the software after any change, so the actual
address is always available.

Yes, the variables will be 'global'. That does not mean that every file/task
has to be told about them via an 'extern' statement. Only two files need to
know about them. The task that sets the values and the clock interrupt handler
that you are writing.

If you are worried about their visibility then:
have a task contain the variables. And contain two functions.
One function to set the variables and one function to return the values from
those variables.
Then the clock interrupt handler calls the function that returns the values.

This is just like many interrupt handlers that need to access some data.

You really do need to have the function that sets the variables make use of some
methodology to inhibit the clock function while the variables are being set,
such that the clock interrupt is not trying to read the variables while they are
being set.

R. Williams

---------- Original Message -----------
From: Andrey Krokhin
To: Richard Williams
Cc: C6x
Sent: Fri, 12 Nov 2010 15:27:04 -0600
Subject: Re: [c6x] Passing parameters to a Clock function in SYS/BIOS

> Hello Richard,
>
> Thanks for your advice. My understanding is that you suggest to define
> variables at some fixed memory addresses. For a SYS/BIOS project, I
> couldn't implement this, please see this thread
>
> http://e2e.ti.com/support/dsp/c6000_multi-
core_dsps/f/439/p/70452/258195.aspx#258195
>
> The second problem is, even if I worked to implement the mutex and
> checks you described, it seems that the solution would be equivalent
> to using global variables, which are placed in some defined locations
> in memory (LL2 and SL2 RAM). No stack variables would be possible.
>
> Furthermore, if I could define custom memory locations in SYS/BIOS
> (see the thread above), the memory layout of these global variables
> would have to change when the number of variables or their size
> changes. For example, if you have a 100-int array, and then changed it
> 200-int, all memory locations that follow these arrays would have to
> be shifted.
>
> So, from your reply, I guess there is no simple solution to it, and
> "Clock" (I mean ti.sysbios.knl.Clock module) is primarily intended for
> arg-less tasks.
>
> Andrey
>
> On 11/11/2010 5:21 PM, Richard Williams wrote:
> >
> > Andrey,
> >
> > There are a couple of ways to go about this.
> >
> > Here is my suggestion:
> > Have the clock function load values from known locations in RAM.
> > Use a mutex (or similar) to kill interrupts (or at least the clock
> > interrupt)
> > while the main program is updating those known locations in RAM.
> >
> > *I* would also have the clock function clear those same variables to
> > NULL, 0
> > during its' execution.
> > Then when reading those known locations, have a 'safety' check that
> > the known
> > locations actually contain fresh data before using the data.
> > I.E contain something besides NULL, 0.
> >
> > BTW:
> > when you say 'clock' do you actually mean the RTC or one of the timers?
> >
> > R. Williams
> >
> > ---------- Original Message -----------
> > From: Andrey Krokhin > > >
> > To: C6x >
> > Sent: Thu, 11 Nov 2010 10:19:33 -0600
> > Subject: [c6x] Passing parameters to a Clock function in SYS/BIOS
> >
> > > Hello,
> > >
> > > I am trying to build a program that uses SYS/BIOS (aka BIOS 6) with CCS
> > > 4.2. The BIOS "Clock" module can be set up to run a function either
> > > periodically or only once ("one-shot"). In my case, I need to run it
> > > only once. Setting up and initializing the clock is not a problem:
> > >
> > > Clock_Handle clk;
> > >
> > > Clock_Params clkParams;
> > >
> > > Clock_Params_init(&clkParams);
> > >
> > > clkParams.period = 0;
> > >
> > > clkParams.startFlag = FALSE;
> > >
> > > clk = Clock_create(myFunc, 1, &clkParams, NULL);
> > >
> > > Clock_start(clk);
> > >
> > > In Clock_create, I am setting up the clock to execute "myFunc". What I
> > > don't know how to do is pass parameters into myFunc. From BIOS
> > > documentation, the only way I saw is to define the optional clock
> > argument:
> > >
> > > clkParams.arg = (UArg)0x1234; /* set up a flag for the clock */
> > >
> > > However, that's just a single 32-bit value. What I need is to pass
> > > arbitrary parameters, which might include different primitive types,
> > > pointers, and structures, into myFunc. Suppose myFunc is defined as:
> > >
> > > void myFunc(int* x, size_t x_len);
> > >
> > > Is there a way to do it? It seems that not being able to pass
> > > parameters to functions, either periodic or one-shot, would be a
> > > significant restriction. I am sure it can be done, I just lack
> > > knowledge on SYS/BIOS.
> > >
> > > Thanks,
> > > Andrey
> > ------- End of Original Message -------
> >
> >
>
> _____________________________________

_____________________________________
Reply by Andrey Krokhin November 12, 20102010-11-12
Hello Richard,

Thanks for your advice. My understanding is that you suggest to define
variables at some fixed memory addresses. For a SYS/BIOS project, I
couldn't implement this, please see this thread

http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/439/p/70452/258195.aspx#258195

The second problem is, even if I worked to implement the mutex and
checks you described, it seems that the solution would be equivalent to
using global variables, which are placed in some defined locations in
memory (LL2 and SL2 RAM). No stack variables would be possible.

Furthermore, if I could define custom memory locations in SYS/BIOS (see
the thread above), the memory layout of these global variables would
have to change when the number of variables or their size changes. For
example, if you have a 100-int array, and then changed it 200-int, all
memory locations that follow these arrays would have to be shifted.

So, from your reply, I guess there is no simple solution to it, and
"Clock" (I mean ti.sysbios.knl.Clock module) is primarily intended for
arg-less tasks.

Andrey
On 11/11/2010 5:21 PM, Richard Williams wrote:
>
> Andrey,
>
> There are a couple of ways to go about this.
>
> Here is my suggestion:
> Have the clock function load values from known locations in RAM.
> Use a mutex (or similar) to kill interrupts (or at least the clock
> interrupt)
> while the main program is updating those known locations in RAM.
>
> *I* would also have the clock function clear those same variables to
> NULL, 0
> during its' execution.
> Then when reading those known locations, have a 'safety' check that
> the known
> locations actually contain fresh data before using the data.
> I.E contain something besides NULL, 0.
>
> BTW:
> when you say 'clock' do you actually mean the RTC or one of the timers?
>
> R. Williams
>
> ---------- Original Message -----------
> From: Andrey Krokhin > >
> To: C6x >
> Sent: Thu, 11 Nov 2010 10:19:33 -0600
> Subject: [c6x] Passing parameters to a Clock function in SYS/BIOS
>
> > Hello,
> >
> > I am trying to build a program that uses SYS/BIOS (aka BIOS 6) with CCS
> > 4.2. The BIOS "Clock" module can be set up to run a function either
> > periodically or only once ("one-shot"). In my case, I need to run it
> > only once. Setting up and initializing the clock is not a problem:
> >
> > Clock_Handle clk;
> >
> > Clock_Params clkParams;
> >
> > Clock_Params_init(&clkParams);
> >
> > clkParams.period = 0;
> >
> > clkParams.startFlag = FALSE;
> >
> > clk = Clock_create(myFunc, 1, &clkParams, NULL);
> >
> > Clock_start(clk);
> >
> > In Clock_create, I am setting up the clock to execute "myFunc". What I
> > don't know how to do is pass parameters into myFunc. From BIOS
> > documentation, the only way I saw is to define the optional clock
> argument:
> >
> > clkParams.arg = (UArg)0x1234; /* set up a flag for the clock */
> >
> > However, that's just a single 32-bit value. What I need is to pass
> > arbitrary parameters, which might include different primitive types,
> > pointers, and structures, into myFunc. Suppose myFunc is defined as:
> >
> > void myFunc(int* x, size_t x_len);
> >
> > Is there a way to do it? It seems that not being able to pass
> > parameters to functions, either periodic or one-shot, would be a
> > significant restriction. I am sure it can be done, I just lack
> > knowledge on SYS/BIOS.
> >
> > Thanks,
> > Andrey
> ------- End of Original Message -------

_____________________________________
Reply by Andrew Nesterov November 12, 20102010-11-12
Dear All,

There's something strange with the SYS/BIOS documentation on the
TI web site. I was able to find the User's Guide - spruex3e.pdf,
but there are no traces of the API manual. Does anybody knows
where is it? Or is it can be found only in the CCS 4 installation?

Thanks,
Andrew

_____________________________________
Reply by Richard Williams November 11, 20102010-11-11
Andrey,

There are a couple of ways to go about this.

Here is my suggestion:
Have the clock function load values from known locations in RAM.
Use a mutex (or similar) to kill interrupts (or at least the clock interrupt)
while the main program is updating those known locations in RAM.

*I* would also have the clock function clear those same variables to NULL, 0
during its' execution.
Then when reading those known locations, have a 'safety' check that the known
locations actually contain fresh data before using the data.
I.E contain something besides NULL, 0.

BTW:
when you say 'clock' do you actually mean the RTC or one of the timers?
R. Williams

---------- Original Message -----------
From: Andrey Krokhin
To: C6x
Sent: Thu, 11 Nov 2010 10:19:33 -0600
Subject: [c6x] Passing parameters to a Clock function in SYS/BIOS

> Hello,
>
> I am trying to build a program that uses SYS/BIOS (aka BIOS 6) with CCS
> 4.2. The BIOS "Clock" module can be set up to run a function either
> periodically or only once ("one-shot"). In my case, I need to run it
> only once. Setting up and initializing the clock is not a problem:
>
> Clock_Handle clk;
>
> Clock_Params clkParams;
>
> Clock_Params_init(&clkParams);
>
> clkParams.period = 0;
>
> clkParams.startFlag = FALSE;
>
> clk = Clock_create(myFunc, 1, &clkParams, NULL);
>
> Clock_start(clk);
>
> In Clock_create, I am setting up the clock to execute "myFunc". What I
> don't know how to do is pass parameters into myFunc. From BIOS
> documentation, the only way I saw is to define the optional clock argument:
>
> clkParams.arg = (UArg)0x1234; /* set up a flag for the clock */
>
> However, that's just a single 32-bit value. What I need is to pass
> arbitrary parameters, which might include different primitive types,
> pointers, and structures, into myFunc. Suppose myFunc is defined as:
>
> void myFunc(int* x, size_t x_len);
>
> Is there a way to do it? It seems that not being able to pass
> parameters to functions, either periodic or one-shot, would be a
> significant restriction. I am sure it can be done, I just lack
> knowledge on SYS/BIOS.
>
> Thanks,
> Andrey
------- End of Original Message -------

_____________________________________
Reply by Andrey Krokhin November 11, 20102010-11-11
Hello,

I am trying to build a program that uses SYS/BIOS (aka BIOS 6) with CCS
4.2. The BIOS "Clock" module can be set up to run a function either
periodically or only once ("one-shot"). In my case, I need to run it
only once. Setting up and initializing the clock is not a problem:

Clock_Handle clk;

Clock_Params clkParams;

Clock_Params_init(&clkParams);

clkParams.period = 0;

clkParams.startFlag = FALSE;

clk = Clock_create(myFunc, 1, &clkParams, NULL);

Clock_start(clk);

In Clock_create, I am setting up the clock to execute "myFunc". What I
don't know how to do is pass parameters into myFunc. From BIOS
documentation, the only way I saw is to define the optional clock argument:

clkParams.arg = (UArg)0x1234; /* set up a flag for the clock */

However, that's just a single 32-bit value. What I need is to pass
arbitrary parameters, which might include different primitive types,
pointers, and structures, into myFunc. Suppose myFunc is defined as:

void myFunc(int* x, size_t x_len);

Is there a way to do it? It seems that not being able to pass parameters
to functions, either periodic or one-shot, would be a significant
restriction. I am sure it can be done, I just lack knowledge on SYS/BIOS.

Thanks,
Andrey

_____________________________________