* [ECOS] CYGNUM_HAL_RTC_PERIOD
@ 2006-02-17 13:41 vasantha.rajan
2006-02-17 22:18 ` Chuck McManis
0 siblings, 1 reply; 8+ messages in thread
From: vasantha.rajan @ 2006-02-17 13:41 UTC (permalink / raw)
To: ecos-discuss; +Cc: gary
Hi all,
I have some doubt in CYGNUM_HAL_RTC_PERIOD. I will list my doubts
1. In my code I just want to trigger my alarm for some micro seconds (say for
25 us)
2. right now in my CDL(hal/arm/arm9/excalibur/v2_0b1/cdl) I have my
CYGNUM_HAL_RTC_NUMERATOR as 1000000000, CYGNUM_HAL_RTC_DENOMINATOR as
100. So the clock triggers for every 10000000 ns(ie,10000 us)
3. Now I changed my CYGNUM_HAL_RTC_DENOMINATOR to 10000 so my clock will
trigger for every 100us.
4. So, In my cyg_alarm_initialize() API, if I use 25 + cyg_current_time() as
my trigger time value ,will the alarm function will be triggered in
25us????????or my calculation is wrong??????
Thank you very much
Vasanth
-------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] CYGNUM_HAL_RTC_PERIOD
2006-02-17 13:41 [ECOS] CYGNUM_HAL_RTC_PERIOD vasantha.rajan
@ 2006-02-17 22:18 ` Chuck McManis
2006-02-21 5:10 ` vasantha.rajan
0 siblings, 1 reply; 8+ messages in thread
From: Chuck McManis @ 2006-02-17 22:18 UTC (permalink / raw)
To: vasantha.rajan; +Cc: ecos-discuss
At 05:40 AM 2/17/2006, vasantha.rajan wrote:
>I have some doubt in CYGNUM_HAL_RTC_PERIOD. I will list my doubts
>
>1. In my code I just want to trigger my alarm for some micro seconds (say for
>25 us)
That is a very short time for most systems. Yours especially.
Ignoring other aspects (like how the RTC timer is configured) for the
moment, realize that on average the ARM9 achieves about 1.5 cycles per
instruction. (This from the ARM9 FAQ) and that when clocked at 150Mhz
(which the Excalibur board apparently is) that's roughly 100 million
instructions per section. So 25 micro seconds is roughly 2500 instructions.
At 3 instructions per line of C code (on average) that's about 833 lines of
C code between clock ticks.
Perhaps you need some specialized hardware to meet this timing requirement?
--Chuck
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] CYGNUM_HAL_RTC_PERIOD
2006-02-17 22:18 ` Chuck McManis
@ 2006-02-21 5:10 ` vasantha.rajan
2006-02-21 7:54 ` Gary Thomas
[not found] ` <43FADFC7.90709@zurich.ibm.com>
0 siblings, 2 replies; 8+ messages in thread
From: vasantha.rajan @ 2006-02-21 5:10 UTC (permalink / raw)
To: Chuck McManis, ecos-discuss; +Cc: abg
On Saturday 18 February 2006 03:47, you wrote:
> At 05:40 AM 2/17/2006, vasantha.rajan wrote:
Hi Chuck,
thanks for your reply....
I have something to ask..sorry for the lengthy mail below.
1. when I changed my CYGNUM_HAL_RTC_DENOMINATOR value to 1000000, (so that my
clock will trigger for 1us) but in my code after the end of cyg_user_start()
my code got struck (ie the thread I created did'nt execute) Why??????
I will just give my test code below:
void alarm_handler( cyg_handle_t alarm_handle, cyg_addrword_t data )
{
printf("value of count:%d\n",count++);
cyg_flag_setbits(&flag,pattern);
}
void counter_thread(cyg_addrword_t data)
{
while(1)
{
value = 0xfffffffe;
pattern = 1;
mode=CYG_FLAG_WAITMODE_OR ;
cyg_flag_maskbits(&flag,value);
cyg_alarm_initialize( alarm_hdl, 100 + cyg_current_time(), 0 );
value=cyg_flag_wait(&flag,pattern,mode);
}
}
void cyg_user_start()
{
sys_clk = cyg_real_time_clock();
cyg_clock_to_counter( sys_clk, &counter_hdl );
cyg_alarm_create( counter_hdl, alarm_handler, (cyg_addrword_t)&index1,
&alarm_hdl, &alarm_obj );
cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack, STACKSIZE,
&handle, &thread);
cyg_thread_resume(handle);
}
2. when I reduced my CYGNUM_HAL_RTC_DENOMINATOR to 100000, (so that my clock
will trigger for 10us) and in my code if i initialize my alarm to
cyg_alarm_initialize( alarm_hdl, 100000+ cyg_current_time(), 0 ), my alarm
triggered for every 1 sec.
If I reduce my value to 10000 my alarm triggered for every 0.1 sec ie, my
count value increments to 10 for every second and still if reduce my value to
1000 count value increments to 100 for every second,but if I still reduce my
value to 100 ,I expected the count value should increment to 1000,but the
count value increments upto some 350 approx.
and if i still reduce my value to 10 or 1my count only increments to 350
only...why I am not getting the linear increment?????????
Thanks
Vasanth
> >I have some doubt in CYGNUM_HAL_RTC_PERIOD. I will list my doubts
> >
> >1. In my code I just want to trigger my alarm for some micro seconds (say
> > for 25 us)
>
> That is a very short time for most systems. Yours especially.
>
> Ignoring other aspects (like how the RTC timer is configured) for the
> moment, realize that on average the ARM9 achieves about 1.5 cycles per
> instruction. (This from the ARM9 FAQ) and that when clocked at 150Mhz
> (which the Excalibur board apparently is) that's roughly 100 million
> instructions per section. So 25 micro seconds is roughly 2500 instructions.
> At 3 instructions per line of C code (on average) that's about 833 lines of
> C code between clock ticks.
>
> Perhaps you need some specialized hardware to meet this timing requirement?
>
> --Chuck
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] CYGNUM_HAL_RTC_PERIOD
2006-02-21 5:10 ` vasantha.rajan
@ 2006-02-21 7:54 ` Gary Thomas
[not found] ` <43FADFC7.90709@zurich.ibm.com>
1 sibling, 0 replies; 8+ messages in thread
From: Gary Thomas @ 2006-02-21 7:54 UTC (permalink / raw)
To: ecos-discuss
On Tue, 2006-02-21 at 10:40 +0530, vasantha.rajan wrote:
> On Saturday 18 February 2006 03:47, you wrote:
> > At 05:40 AM 2/17/2006, vasantha.rajan wrote:
>
> Hi Chuck,
> thanks for your reply....
>
> I have something to ask..sorry for the lengthy mail below.
>
> 1. when I changed my CYGNUM_HAL_RTC_DENOMINATOR value to 1000000, (so that my
> clock will trigger for 1us) but in my code after the end of cyg_user_start()
> my code got struck (ie the thread I created did'nt execute) Why??????
Unless you have a blazingly fast processor, this is never going to work.
Setting the RTC to *interrupt* in 1us will totally swamp your system as
each clock "tick" will require full interrupt processing which takes
time. On even a fairly fast processor, this will take many
micro-seconds, so you can see the problem.
The system "tick" value of 10ms (10,000 slower than what you've chosen)
is a reasonable compromise. The system can keep track of time, but
still not be saturated by those interrupts.
I suspect that if you have some code that needs to wait for micro-second
scale times, you should be using CYGACC_CALL_IF_DELAY_US(). This will
perform an in-line wait - no thread switching - for the specified number
of micro-seconds. It's not suitable for long periods, especially if
there are other threads that could be doing useful work, but it is
useful for things like device drivers that only need to wait a little
while, e.g. to satisfy some hardware timing constraints.
>
> I will just give my test code below:
>
> void alarm_handler( cyg_handle_t alarm_handle, cyg_addrword_t data )
> {
> printf("value of count:%d\n",count++);
> cyg_flag_setbits(&flag,pattern);
> }
>
> void counter_thread(cyg_addrword_t data)
> {
> while(1)
> {
> value = 0xfffffffe;
> pattern = 1;
> mode=CYG_FLAG_WAITMODE_OR ;
> cyg_flag_maskbits(&flag,value);
>
> cyg_alarm_initialize( alarm_hdl, 100 + cyg_current_time(), 0 );
> value=cyg_flag_wait(&flag,pattern,mode);
> }
> }
>
> void cyg_user_start()
> {
> sys_clk = cyg_real_time_clock();
> cyg_clock_to_counter( sys_clk, &counter_hdl );
> cyg_alarm_create( counter_hdl, alarm_handler, (cyg_addrword_t)&index1,
> &alarm_hdl, &alarm_obj );
> cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack, STACKSIZE,
> &handle, &thread);
> cyg_thread_resume(handle);
> }
>
> 2. when I reduced my CYGNUM_HAL_RTC_DENOMINATOR to 100000, (so that my clock
> will trigger for 10us) and in my code if i initialize my alarm to
> cyg_alarm_initialize( alarm_hdl, 100000+ cyg_current_time(), 0 ), my alarm
> triggered for every 1 sec.
>
> If I reduce my value to 10000 my alarm triggered for every 0.1 sec ie, my
> count value increments to 10 for every second and still if reduce my value to
> 1000 count value increments to 100 for every second,but if I still reduce my
> value to 100 ,I expected the count value should increment to 1000,but the
> count value increments upto some 350 approx.
>
> and if i still reduce my value to 10 or 1my count only increments to 350
> only...why I am not getting the linear increment?????????
>
>
> Thanks
> Vasanth
>
> > >I have some doubt in CYGNUM_HAL_RTC_PERIOD. I will list my doubts
> > >
> > >1. In my code I just want to trigger my alarm for some micro seconds (say
> > > for 25 us)
> >
> > That is a very short time for most systems. Yours especially.
> >
> > Ignoring other aspects (like how the RTC timer is configured) for the
> > moment, realize that on average the ARM9 achieves about 1.5 cycles per
> > instruction. (This from the ARM9 FAQ) and that when clocked at 150Mhz
> > (which the Excalibur board apparently is) that's roughly 100 million
> > instructions per section. So 25 micro seconds is roughly 2500 instructions.
> > At 3 instructions per line of C code (on average) that's about 833 lines of
> > C code between clock ticks.
> >
> > Perhaps you need some specialized hardware to meet this timing requirement?
> >
> > --Chuck
>
>
>
--
Gary Thomas <gary@mlbassoc.com>
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] CYGNUM_HAL_RTC_PERIOD
[not found] ` <200602221019.24844.vasantha.rajan@cranessoftware.com>
@ 2006-02-22 9:01 ` Dirk Husemann
0 siblings, 0 replies; 8+ messages in thread
From: Dirk Husemann @ 2006-02-22 9:01 UTC (permalink / raw)
To: vasantha.rajan; +Cc: mcmanis, ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
vasantha.rajan wrote:
>On Tuesday 21 February 2006 15:09, you wrote:
>
>Hi Dirk ,
>
>Thanks for your reply......
>
>In my previous mail I asked one more question.....but did'nt get reply.
>
>
>
>
[...]
>
> 1. I made CYGNUM_HAL_RTC_DENOMINATOR to 100000, (so that my
> clock will trigger for 10us) and in my code if i initialize my alarm to
>cyg_alarm_initialize( alarm_hdl, 100000 + cyg_current_time(), 0 ), my alarm
> triggered for every 1 sec.
>
> If I reduce my value given to cyg_alarm_initialize() API to 10000 my alarm
>triggered for every 0.1 sec ie, my code
> count value increments to 10 for every second and still if reduce my value
> to 1000 count value increments to 100 for every second,but if I still
> reduce my value to 100 ,I expected the count value should increment to
> 1000,but the count value increments upto some 350 approx.
>
> and if i still reduce my value to 10 or 1 my count only increments to 350
> only...why I am not getting the linear increment?????????
>
>
my suspicion is that your system is increasingly busy/overloaded with
doing interrupts and doesn't have enough cycles left to work through
your thread's code...or in other words: you are using up your system's
resources with servicing/trying to service the timer interrupts and you
have no resources left for pretty much anything else.
--
Dr Dirk Husemann, Pervasive Computing, IBM Research, Zurich Research Lab
hud@zurich.ibm.com --- http://www.zurich.ibm.com/~hud/
PGP key: http://www.zurich.ibm.com/~hud/contact/PGP
PGP Fingerprint: 983C 48E7 0A78 A313 401C C4AD 3C0A 278E 6431 A149
Email only authentic if signed with PGP key.
Appended to this email is an electronic signature attachment. You can
ignore it if your email program does not know how to verify such a
signature. If you'd like to learn more about this topic, www.gnupg.org
is a good starting point.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 258 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] CYGNUM_HAL_RTC_PERIOD
2006-02-22 9:03 vasantha.rajan
@ 2006-02-22 9:32 ` Andrew Lunn
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2006-02-22 9:32 UTC (permalink / raw)
To: vasantha.rajan; +Cc: ecos-discuss
On Wed, Feb 22, 2006 at 02:33:26PM +0530, vasantha.rajan wrote:
>
>
> On Tuesday 21 February 2006 15:09, you wrote:
>
> Hi Dirk ,
>
> Thanks for your reply......
>
> In my previous mail I asked one more question.....but did'nt get reply.
>
> I will give a test code....
>
> int count =1;
>
> void alarm_handler( cyg_handle_t alarm_handle, cyg_addrword_t data )
> {
> printf("value of count:%d\n",count++);
> cyg_flag_setbits(&flag,pattern);
> }
>
> void counter_thread(cyg_addrword_t data)
> {
> while(1)
> {
> value = 0xfffffffe;
> pattern = 1;
> mode=CYG_FLAG_WAITMODE_OR ;
> cyg_flag_maskbits(&flag,value);
>
> cyg_alarm_initialize( alarm_hdl, 100 + cyg_current_time(), 0 );
> value=cyg_flag_wait(&flag,pattern,mode);
> }
> }
>
> void cyg_user_start()
> {
> sys_clk = cyg_real_time_clock();
> cyg_clock_to_counter( sys_clk, &counter_hdl );
> cyg_alarm_create( counter_hdl, alarm_handler,
> (cyg_addrword_t)&index1, &alarm_hdl, &alarm_obj );
> cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack,
> STACKSIZE, &handle, &thread);
> cyg_thread_resume(handle);
> }
>
> 1. I made CYGNUM_HAL_RTC_DENOMINATOR to 100000, (so that my
> clock will trigger for 10us) and in my code if i initialize my alarm to
> cyg_alarm_initialize( alarm_hdl, 100000 + cyg_current_time(), 0 ), my alarm
> triggered for every 1 sec.
>
> If I reduce my value given to cyg_alarm_initialize() API to 10000 my alarm
> triggered for every 0.1 sec ie, my code
> count value increments to 10 for every second and still if reduce my value
> to 1000 count value increments to 100 for every second,but if I still
> reduce my value to 100 ,I expected the count value should increment to
> 1000,but the count value increments upto some 350 approx.
>
> and if i still reduce my value to 10 or 1 my count only increments to 350
> only...why I am not getting the linear increment?????????
Simple. The CPU is 100% busy handling all these interrupts.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ECOS] CYGNUM_HAL_RTC_PERIOD
@ 2006-02-22 9:03 vasantha.rajan
2006-02-22 9:32 ` Andrew Lunn
0 siblings, 1 reply; 8+ messages in thread
From: vasantha.rajan @ 2006-02-22 9:03 UTC (permalink / raw)
To: gary, hud, cmcmanis; +Cc: ecos-discuss
On Tuesday 21 February 2006 15:09, you wrote:
Hi Dirk ,
Thanks for your reply......
In my previous mail I asked one more question.....but did'nt get reply.
I will give a test code....
int count =1;
void alarm_handler( cyg_handle_t alarm_handle, cyg_addrword_t data )
{
printf("value of count:%d\n",count++);
cyg_flag_setbits(&flag,pattern);
}
void counter_thread(cyg_addrword_t data)
{
while(1)
{
value = 0xfffffffe;
pattern = 1;
mode=CYG_FLAG_WAITMODE_OR ;
cyg_flag_maskbits(&flag,value);
cyg_alarm_initialize( alarm_hdl, 100 + cyg_current_time(), 0 );
value=cyg_flag_wait(&flag,pattern,mode);
}
}
void cyg_user_start()
{
sys_clk = cyg_real_time_clock();
cyg_clock_to_counter( sys_clk, &counter_hdl );
cyg_alarm_create( counter_hdl, alarm_handler,
(cyg_addrword_t)&index1, &alarm_hdl, &alarm_obj );
cyg_thread_create(10, &counter_thread, 0 ,"counter_thread", stack,
STACKSIZE, &handle, &thread);
cyg_thread_resume(handle);
}
1. I made CYGNUM_HAL_RTC_DENOMINATOR to 100000, (so that my
clock will trigger for 10us) and in my code if i initialize my alarm to
cyg_alarm_initialize( alarm_hdl, 100000 + cyg_current_time(), 0 ), my alarm
triggered for every 1 sec.
If I reduce my value given to cyg_alarm_initialize() API to 10000 my alarm
triggered for every 0.1 sec ie, my code
count value increments to 10 for every second and still if reduce my value
to 1000 count value increments to 100 for every second,but if I still
reduce my value to 100 ,I expected the count value should increment to
1000,but the count value increments upto some 350 approx.
and if i still reduce my value to 10 or 1 my count only increments to 350
only...why I am not getting the linear increment?????????
Thanks
Vasanth
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [ECOS] CYGNUM_HAL_RTC_PERIOD
@ 2006-02-17 14:11 Àlex Bueno Guarner
0 siblings, 0 replies; 8+ messages in thread
From: Àlex Bueno Guarner @ 2006-02-17 14:11 UTC (permalink / raw)
To: vasantha.rajan, ecos-discuss; +Cc: gary
I think that if your clock triggers every 100us, it's not possible to trigger the alarm for 25us.
When you initialize an alarm, the value you pass to cyg_alarm_initialize must be in the units the system uses. As you are using a clock with a trigger of 100us, the time value is calculated in increments of 100us.
If you want to be able to use delays of "us", the timer must be configured to trigger every "us". Depending on the hardware used, this frequency of ints can make the system not to work properly, because the timer interrupt calls some kernel functions. Be aware.
Maybe there is another way to give "us" precision to the system, but I don't know.
Alex Bueno
-----Mensaje original-----
De: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] En nombre de vasantha.rajan
Enviado el: viernes, 17 de febrero de 2006 14:41
Para: ecos-discuss@ecos.sourceware.org
CC: gary@mlbassoc.com
Asunto: [ECOS] CYGNUM_HAL_RTC_PERIOD
Hi all,
I have some doubt in CYGNUM_HAL_RTC_PERIOD. I will list my doubts
1. In my code I just want to trigger my alarm for some micro seconds (say for
25 us)
2. right now in my CDL(hal/arm/arm9/excalibur/v2_0b1/cdl) I have my CYGNUM_HAL_RTC_NUMERATOR as 1000000000, CYGNUM_HAL_RTC_DENOMINATOR as 100. So the clock triggers for every 10000000 ns(ie,10000 us)
3. Now I changed my CYGNUM_HAL_RTC_DENOMINATOR to 10000 so my clock will trigger for every 100us.
4. So, In my cyg_alarm_initialize() API, if I use 25 + cyg_current_time() as my trigger time value ,will the alarm function will be triggered in 25us????????or my calculation is wrong??????
Thank you very much
Vasanth
-------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-02-22 9:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-17 13:41 [ECOS] CYGNUM_HAL_RTC_PERIOD vasantha.rajan
2006-02-17 22:18 ` Chuck McManis
2006-02-21 5:10 ` vasantha.rajan
2006-02-21 7:54 ` Gary Thomas
[not found] ` <43FADFC7.90709@zurich.ibm.com>
[not found] ` <200602221019.24844.vasantha.rajan@cranessoftware.com>
2006-02-22 9:01 ` Dirk Husemann
2006-02-17 14:11 Àlex Bueno Guarner
2006-02-22 9:03 vasantha.rajan
2006-02-22 9:32 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).