public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Problems with eCos clocks
@ 2001-08-29 14:19 Chris Sekula
  2001-09-06 23:32 ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Sekula @ 2001-08-29 14:19 UTC (permalink / raw)
  To: ecos-discuss

1. The resolution of the real time clock in the default configuration is
10 milliseconds. However, for an application that I am writing, I need a
clock with a resolution of about 100 microseconds. I tried to create a
clock with a 100 microsecond resolution using the API listed on p.36 of
the eCos Reference Manual (September 2000). I created a cyg_resolution_t
structure and set the dividend and divisor appropriately (one billion
and ten thousand) for a 100 microsecond resolution. I called
cyg_counter_create to create a counter and the cyg_clock_create function
to create the clock with the desired resolution. I then used the
cyg_clock_to_counter function to obtain a handle to the counter
(huCounter).  I used the following code snippet to test the clock:

printf("Starting timing loop \n");

while (!bkill)

{

      t2 = cyg_counter_current_value(huCounter);

      dt = t2-t1;

      if (dt >500)

      {

            bkill = true;

      printf("end loop \n");

      }

}

printf("# of clock ticks = %d \n", dt);

With a clock resolution of 100 microseconds, I was expecting the while
loop to end after 500 clock ticks, or 50 milliseconds. Instead, the
program hung. I modified the above code so that the loop would exit
after a few seconds (based upon timing from the real time clock) and
examined the values of t1, t2 and dt. These values were all zero.

2. What is required to create and run a clock with a finer resolution
than that of the real time clock? Is the API for clocks and counters
sufficient, or is it necessary to set a microprocessor timer and write
an interrupt handler to handle the overflow of the timer and increment a
counter appropriately?

3. I tried to modify the resolution of the real time clock in code by
obtaining a handle to the RTC with cyg_real_time_clock() and then trying
cyg_clock_set_resolution with the appropriate resolution. When I ran my
test code, the while loop exited after about 5 seconds, corresponding to
500 ticks of 10 milliseconds per tick. Therefore, the function
cyg_clock_set_resolution had no effect on changing the resolution of the
real time clock. Is it possible to change the resolution of the RTC in
code?

4. Using the eCos Config Tool, Under the option 'ECos Kernel', 'Counters
and clocks', I selected the option 'Override default clock settings' and
then modified the clock resolution numerator and denominator to one
billion and ten thousand respectively (I wasn't sure what to set the
Clock Hardware Initialization value to, so I left it). I rebuilt eCos
and compiled it with my test program. In my test program, I also checked
what the resolution of the RTC was with the function
cyg_clock_get_resolution. I obtained the correct values for the dividend
and divisor for the new settings (one billion and ten thousand), but my
while loop exited after 5 seconds, indicating that the resolution of the
RTC was unaffected.

5. I checked two of the include files generated by the Configuration
Tool: \install\include\pkconfig\kernel.h and
\install\include\pkconfig\hal_i386_pcmb.h. I noticed that the value of
CYGNUM_HAL_RTC_DENOMINATOR retained the initial value of 100 as opposed
to the new value of 10000 that I had set in the Config Tool. I manually
changed the value of the denominator to 10000 and recompiled the code.
My code produced the same result: an exit from the loop after 5 seconds.

6. What steps are required to reconfigure the resolution of the Real
Time Clock with the Configuration Tool?

Regards,

CHRIS.

 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Problems with eCos clocks
  2001-08-29 14:19 [ECOS] Problems with eCos clocks Chris Sekula
@ 2001-09-06 23:32 ` Jonathan Larmour
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Larmour @ 2001-09-06 23:32 UTC (permalink / raw)
  To: Chris Sekula; +Cc: ecos-discuss

Chris Sekula wrote:
> 
> 2. What is required to create and run a clock with a finer resolution
> than that of the real time clock?

You can't.

> Is the API for clocks and counters
> sufficient, or is it necessary to set a microprocessor timer and write
> an interrupt handler to handle the overflow of the timer and increment a
> counter appropriately?

If possible increase the resolution of the RTC.
 
> 3. I tried to modify the resolution of the real time clock in code by
> obtaining a handle to the RTC with cyg_real_time_clock() and then trying
> cyg_clock_set_resolution with the appropriate resolution. When I ran my
> test code, the while loop exited after about 5 seconds, corresponding to
> 500 ticks of 10 milliseconds per tick. Therefore, the function
> cyg_clock_set_resolution had no effect on changing the resolution of the
> real time clock. Is it possible to change the resolution of the RTC in
> code?

Setting the resolution of the RTC handle won't actually change the
frequency the hardware interrupts at. If anything, the resolution is simply
a consequence of the period. Setting the resolution is only interesting for
counters/clocks triggered indirectly off the underlying RTC.

> 4. Using the eCos Config Tool, Under the option 'ECos Kernel', 'Counters
> and clocks', I selected the option 'Override default clock settings' and
> then modified the clock resolution numerator and denominator to one
> billion and ten thousand respectively (I wasn't sure what to set the
> Clock Hardware Initialization value to, so I left it).

That initialization value is actually what you need to change. The correct
value is determined by your hardware.

> 5. I checked two of the include files generated by the Configuration
> Tool: \install\include\pkconfig\kernel.h and
> \install\include\pkconfig\hal_i386_pcmb.h. I noticed that the value of
> CYGNUM_HAL_RTC_DENOMINATOR retained the initial value of 100 as opposed
> to the new value of 10000 that I had set in the Config Tool. I manually
> changed the value of the denominator to 10000 and recompiled the code.
> My code produced the same result: an exit from the loop after 5 seconds.
> 
> 6. What steps are required to reconfigure the resolution of the Real
> Time Clock with the Configuration Tool?

Change the override value of the clock hardware initialization value. Look
at hal/i386/pcmb/current/src/pcmb_misc.c for the clock initialize code.
From that, and a PC hardware book, you can determine the new value to use
for your application. Then you make the overridden numerator and
denominator for the RTC resolution reflect that new period.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS] Problems with eCos clocks
@ 2001-09-05 11:11 Chris Sekula
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Sekula @ 2001-09-05 11:11 UTC (permalink / raw)
  To: ecos-discuss

1. The resolution of the real time clock in the default configuration is
10 milliseconds. However, for an application that I am writing, I need a
clock with a resolution of about 100 microseconds. I tried to create a
clock with a 100 microsecond resolution using the API listed on p.36 of
the eCos Reference Manual (September 2000). I created a cyg_resolution_t
structure and set the dividend and divisor appropriately (one billion
and ten thousand) for a 100 microsecond resolution. I called
cyg_counter_create to create a counter and the cyg_clock_create function
to create the clock with the desired resolution. I then used the
cyg_clock_to_counter function to obtain a handle to the counter
(huCounter).  I used the following code snippet to test the clock:

cyg_tick_count_t dt, t1, t2;

bool bkill = false;

printf("Starting timing loop \n");

t1 = cyg_counter_current_value(huCounter);

while (!bkill)

{

      t2 = cyg_counter_current_value(huCounter);

      dt = t2-t1;

      if (dt >500)

      {

            bkill = true;

           printf("end loop \n");

      }

}

printf("# of clock ticks = %d \n", dt);

With a clock resolution of 100 microseconds, I was expecting the while
loop to end after 500 clock ticks, or 50 milliseconds. Instead, the
program hung. I modified the above code so that the loop would exit
after a few seconds (based upon timing from the real time clock) and
examined the values of t1, t2 and dt. These values were all zero.

2. What is required to create and run a clock with a finer resolution
than that of the real time clock? Is the API for clocks and counters
sufficient, or is it necessary to set a microprocessor timer and write
an interrupt handler to handle the overflow of the timer and increment a
counter appropriately?

3. I tried to modify the resolution of the real time clock in code by
obtaining a handle to the RTC with cyg_real_time_clock() and then trying
cyg_clock_set_resolution with the appropriate resolution. When I ran my
test code, the while loop exited after about 5 seconds, corresponding to
500 ticks of 10 milliseconds per tick. Therefore, the function
cyg_clock_set_resolution had no effect on changing the resolution of the
real time clock. Is it possible to change the resolution of the RTC in
code?

4. Using the eCos Config Tool, Under the option 'ECos Kernel', 'Counters
and clocks', I selected the option 'Override default clock settings' and
then modified the clock resolution numerator and denominator to one
billion and ten thousand respectively (I wasn't sure what to set the
Clock Hardware Initialization value to, so I left it). I rebuilt eCos
and compiled it with my test program. In my test program, I also checked
what the resolution of the RTC was with the function
cyg_clock_get_resolution. I obtained the correct values for the dividend
and divisor for the new settings (one billion and ten thousand), but my
while loop exited after 5 seconds, indicating that the resolution of the
RTC was unaffected.

5. I checked two of the include files generated by the Configuration
Tool: \install\include\pkconfig\kernel.h and
\install\include\pkconfig\hal_i386_pcmb.h. I noticed that the value of
CYGNUM_HAL_RTC_DENOMINATOR retained the initial value of 100 as opposed
to the new value of 10000 that I had set in the Config Tool. I manually
changed the value of the denominator to 10000 and recompiled the code.
My code produced the same result: an exit from the loop after 5 seconds.

6. What steps are required to reconfigure the resolution of the Real
Time Clock with the Configuration Tool?

Regards,

CHRIS.

 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS] Problems with eCos Clocks
@ 2001-08-31  6:44 Chris Sekula
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Sekula @ 2001-08-31  6:44 UTC (permalink / raw)
  To: ecos-discuss

1. The resolution of the real time clock in the default configuration is
10 milliseconds. However, for an application that I am writing, I need a
clock with a resolution of about 100 microseconds. I tried to create a
clock with a 100 microsecond resolution using the API listed on p.36 of
the eCos Reference Manual (September 2000). I created a cyg_resolution_t
structure and set the dividend and divisor appropriately (one billion
and ten thousand) for a 100 microsecond resolution. I called
cyg_counter_create to create a counter and the cyg_clock_create function
to create the clock with the desired resolution. I then used the
cyg_clock_to_counter function to obtain a handle to the counter
(huCounter).  I used the following code snippet to test the clock:

cyg_tick_count_t dt, t1, t2;

bool bkill = false;

printf("Starting timing loop \n");

t1 = cyg_counter_current_value(huCounter);

while (!bkill)

{

      t2 = cyg_counter_current_value(huCounter);

      dt = t2-t1;

      if (dt >500)

      {

            bkill = true;

           printf("end loop \n");

      }

}

printf("# of clock ticks = %d \n", dt);

With a clock resolution of 100 microseconds, I was expecting the while
loop to end after 500 clock ticks, or 50 milliseconds. Instead, the
program hung. I modified the above code so that the loop would exit
after a few seconds (based upon timing from the real time clock) and
examined the values of t1, t2 and dt. These values were all zero.

2. What is required to create and run a clock with a finer resolution
than that of the real time clock? Is the API for clocks and counters
sufficient, or is it necessary to set a microprocessor timer and write
an interrupt handler to handle the overflow of the timer and increment a
counter appropriately?

3. I tried to modify the resolution of the real time clock in code by
obtaining a handle to the RTC with cyg_real_time_clock() and then trying
cyg_clock_set_resolution with the appropriate resolution. When I ran my
test code, the while loop exited after about 5 seconds, corresponding to
500 ticks of 10 milliseconds per tick. Therefore, the function
cyg_clock_set_resolution had no effect on changing the resolution of the
real time clock. Is it possible to change the resolution of the RTC in
code?

4. Using the eCos Config Tool, Under the option 'ECos Kernel', 'Counters
and clocks', I selected the option 'Override default clock settings' and
then modified the clock resolution numerator and denominator to one
billion and ten thousand respectively (I wasn't sure what to set the
Clock Hardware Initialization value to, so I left it). I rebuilt eCos
and compiled it with my test program. In my test program, I also checked
what the resolution of the RTC was with the function
cyg_clock_get_resolution. I obtained the correct values for the dividend
and divisor for the new settings (one billion and ten thousand), but my
while loop exited after 5 seconds, indicating that the resolution of the
RTC was unaffected.

5. I checked two of the include files generated by the Configuration
Tool: \install\include\pkconfig\kernel.h and
\install\include\pkconfig\hal_i386_pcmb.h. I noticed that the value of
CYGNUM_HAL_RTC_DENOMINATOR retained the initial value of 100 as opposed
to the new value of 10000 that I had set in the Config Tool. I manually
changed the value of the denominator to 10000 and recompiled the code.
My code produced the same result: an exit from the loop after 5 seconds.

6. What steps are required to reconfigure the resolution of the Real
Time Clock with the Configuration Tool?

Regards,

CHRIS.

 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-09-06 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-29 14:19 [ECOS] Problems with eCos clocks Chris Sekula
2001-09-06 23:32 ` Jonathan Larmour
2001-08-31  6:44 [ECOS] Problems with eCos Clocks Chris Sekula
2001-09-05 11:11 [ECOS] Problems with eCos clocks Chris Sekula

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).