public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] eCos heartbeat function handler
@ 2009-07-19  8:08 Nodir Qodirov
  2009-07-19  8:18 ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Nodir Qodirov @ 2009-07-19  8:08 UTC (permalink / raw)
  To: ecos-discuss

Hello everybody!

I want to know "heartbeat" function of the eCos.

As far as I know, all Embedded Systems have CPU provided or external
source of ticks, which is can be thought as "heartbeat" of system. And
it can have different rates depending on h/w.

I have read eCos reference and previous posts in ecos-discuss, but
couldn't find which function is run on each tick?

From eCos book of Anthony J. Massa and eCos Ref I found that Clock,
Alarm and Timer are attached to the Counter, so I thought some
function of Counter  (as it is basement for others) should have
heartbeat handler function.

Then I had a look to the source code and found

void Cyg_Counter::tick( cyg_uint32 ticks )

function in

packages\kernel\current\src\common\clock.cxx

it seemed to be function which is called at each tick. Am I right?

Basically I have 2 questions:

1) Which function is called on each heartbeat (=hardware provided
source of ticks)?

2) Where should I specify (some assembler file...) which function to
call on each heartbeat?

Thanking in advence,
Nodir.

-- 
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] 7+ messages in thread

* Re: [ECOS] eCos heartbeat function handler
  2009-07-19  8:08 [ECOS] eCos heartbeat function handler Nodir Qodirov
@ 2009-07-19  8:18 ` Andrew Lunn
  2009-07-19 14:07   ` Nodir Qodirov
  2009-08-05 11:22   ` Ormund Williams
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Lunn @ 2009-07-19  8:18 UTC (permalink / raw)
  To: Nodir Qodirov; +Cc: ecos-discuss

> 2) Where should I specify (some assembler file...) which function to
> call on each heartbeat?

Take a look at:

http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html

Call 
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);

and you alarm function will be called every tick.

    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] 7+ messages in thread

* Re: [ECOS] eCos heartbeat function handler
  2009-07-19  8:18 ` Andrew Lunn
@ 2009-07-19 14:07   ` Nodir Qodirov
  2009-07-19 14:47     ` Christophe Coutand
  2009-08-05 11:22   ` Ormund Williams
  1 sibling, 1 reply; 7+ messages in thread
From: Nodir Qodirov @ 2009-07-19 14:07 UTC (permalink / raw)
  To: Nodir Qodirov, ecos-discuss

Thank you Andrew!

I think your answer is from eCos application programmer's view, I want
to know tick handler function from system designer/developer point of
view.

For example in the example which you gave at

http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html

I initialize alarm and it will be called whenever it reaches given clock ticks.
In this case
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
I'm just creating timer with the period of one tick and asking
re-trigger this alarm periodically. If I run this example (at
clocks-and-alarm-handlers.html) on my i386 board, it works fine, but
there is some function which is receiving hardware ticks and making
all eCos alarms to work. What is that function?

Maybe I can paraphrase my question simple as: which function in eCos
kernel is handling hardware clock tick (or clock tick interrupts) ?


2009/7/19 Andrew Lunn <andrew@lunn.ch>:
>> 2) Where should I specify (some assembler file...) which function to
>> call on each heartbeat?
>
> Take a look at:
>
> http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html
>
> Call
> cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
>
> and you alarm function will be called every tick.
>
>    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] 7+ messages in thread

* RE: [ECOS] eCos heartbeat function handler
  2009-07-19 14:07   ` Nodir Qodirov
@ 2009-07-19 14:47     ` Christophe Coutand
  2009-07-21  6:52       ` Nodir Qodirov
  0 siblings, 1 reply; 7+ messages in thread
From: Christophe Coutand @ 2009-07-19 14:47 UTC (permalink / raw)
  To: Nodir Qodirov, ecos-discuss

I believe what you are looking for is located in:

kernel\current\src\common\clock.cxx

The clock is created here and attached to the HW interrupt:

Cyg_RealTimeClock::Cyg_RealTimeClock()
    : Cyg_Clock(rtc_resolution),
      interrupt(CYGNUM_HAL_INTERRUPT_RTC,
                CYGNUM_KERNEL_COUNTERS_CLOCK_ISR_PRIORITY,
                (CYG_ADDRWORD)this, isr, dsr)
{
    CYG_REPORT_FUNCTION();
    HAL_CLOCK_INITIALIZE( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD);
    interrupt.attach();
    interrupt.unmask_interrupt(CYGNUM_HAL_INTERRUPT_RTC);
    Cyg_Clock::real_time_clock = this;
}

The tick value is incremented from the DSR:

void Cyg_RealTimeClock::dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
    rtc->tick( count );

The period of the RTC clock is configurable from your .ecc file.

Christophe

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Nodir Qodirov
Sent: Sunday, July 19, 2009 4:07 PM
To: Nodir Qodirov; ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] eCos heartbeat function handler

Thank you Andrew!

I think your answer is from eCos application programmer's view, I want
to know tick handler function from system designer/developer point of
view.

For example in the example which you gave at

http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html

I initialize alarm and it will be called whenever it reaches given clock ticks.
In this case
cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
I'm just creating timer with the period of one tick and asking
re-trigger this alarm periodically. If I run this example (at
clocks-and-alarm-handlers.html) on my i386 board, it works fine, but
there is some function which is receiving hardware ticks and making
all eCos alarms to work. What is that function?

Maybe I can paraphrase my question simple as: which function in eCos
kernel is handling hardware clock tick (or clock tick interrupts) ?


2009/7/19 Andrew Lunn <andrew@lunn.ch>:
>> 2) Where should I specify (some assembler file...) which function to
>> call on each heartbeat?
>
> Take a look at:
>
> http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html
>
> Call
> cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
>
> and you alarm function will be called every tick.
>
>    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


--
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] 7+ messages in thread

* Re: [ECOS] eCos heartbeat function handler
  2009-07-19 14:47     ` Christophe Coutand
@ 2009-07-21  6:52       ` Nodir Qodirov
  2009-07-21  7:27         ` Christophe Coutand
  0 siblings, 1 reply; 7+ messages in thread
From: Nodir Qodirov @ 2009-07-21  6:52 UTC (permalink / raw)
  To: Christophe Coutand; +Cc: ecos-discuss

Thank you Christophe! This is exactly the same which I was looking for!

After further analyze I got answer to several my questions, including
responsibility of Cyg_RealTimeClock class.

But there is one more question, where I'm having little difficulty.
That is: after h/w tick interrupt - first ISR of that interrupt then
DSR is called. And as you told:

> The tick value is incremented from the DSR:
>
> void Cyg_RealTimeClock::dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
>    rtc->tick( count );

and in tick( cyg_uint32 ticks ) function there is loop
(\kernel\current\src\common\clock.cxx) :

while( ticks-- )
{
...
}

where *ticks* is the value provided by call from DSR. So, my confusion
is what is value of this *ticks* and why we need decrement it in
*while* loop?

There is comment in source code:

// Increment the counter in a loop so we process
// each tick separately. This is easier than trying
// to cope with a range of increments.

but, couldn't get any idea.


2009/7/19 Christophe Coutand <ccoutand@stmi.com>:
> I believe what you are looking for is located in:
>
> kernel\current\src\common\clock.cxx
>
> The clock is created here and attached to the HW interrupt:
>
> Cyg_RealTimeClock::Cyg_RealTimeClock()
>    : Cyg_Clock(rtc_resolution),
>      interrupt(CYGNUM_HAL_INTERRUPT_RTC,
>                CYGNUM_KERNEL_COUNTERS_CLOCK_ISR_PRIORITY,
>                (CYG_ADDRWORD)this, isr, dsr)
> {
>    CYG_REPORT_FUNCTION();
>    HAL_CLOCK_INITIALIZE( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD);
>    interrupt.attach();
>    interrupt.unmask_interrupt(CYGNUM_HAL_INTERRUPT_RTC);
>    Cyg_Clock::real_time_clock = this;
> }
>
> The tick value is incremented from the DSR:
>
> void Cyg_RealTimeClock::dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
>    rtc->tick( count );
>
> The period of the RTC clock is configurable from your .ecc file.
>
> Christophe
>

--
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] 7+ messages in thread

* RE: [ECOS] eCos heartbeat function handler
  2009-07-21  6:52       ` Nodir Qodirov
@ 2009-07-21  7:27         ` Christophe Coutand
  0 siblings, 0 replies; 7+ messages in thread
From: Christophe Coutand @ 2009-07-21  7:27 UTC (permalink / raw)
  To: Nodir Qodirov; +Cc: ecos-discuss

Commonly the DSRs routines are supplied with a count value which is the number of time the ISR was called before the DSR is actually served. This is the reason for having the while loop.

The tick counter is incremented inside the while loop:
counter += increment;

increment is initialized to 1.

Christophe

-----Original Message-----
From: Nodir Qodirov [mailto:nodir.qodirov@gmail.com] 
Sent: Tuesday, July 21, 2009 8:52 AM
To: Christophe Coutand
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] eCos heartbeat function handler

Thank you Christophe! This is exactly the same which I was looking for!

After further analyze I got answer to several my questions, including
responsibility of Cyg_RealTimeClock class.

But there is one more question, where I'm having little difficulty.
That is: after h/w tick interrupt - first ISR of that interrupt then
DSR is called. And as you told:

> The tick value is incremented from the DSR:
>
> void Cyg_RealTimeClock::dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
>    rtc->tick( count );

and in tick( cyg_uint32 ticks ) function there is loop
(\kernel\current\src\common\clock.cxx) :

while( ticks-- )
{
...
}

where *ticks* is the value provided by call from DSR. So, my confusion
is what is value of this *ticks* and why we need decrement it in
*while* loop?

There is comment in source code:

// Increment the counter in a loop so we process
// each tick separately. This is easier than trying
// to cope with a range of increments.

but, couldn't get any idea.


2009/7/19 Christophe Coutand <ccoutand@stmi.com>:
> I believe what you are looking for is located in:
>
> kernel\current\src\common\clock.cxx
>
> The clock is created here and attached to the HW interrupt:
>
> Cyg_RealTimeClock::Cyg_RealTimeClock()
>    : Cyg_Clock(rtc_resolution),
>      interrupt(CYGNUM_HAL_INTERRUPT_RTC,
>                CYGNUM_KERNEL_COUNTERS_CLOCK_ISR_PRIORITY,
>                (CYG_ADDRWORD)this, isr, dsr)
> {
>    CYG_REPORT_FUNCTION();
>    HAL_CLOCK_INITIALIZE( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD);
>    interrupt.attach();
>    interrupt.unmask_interrupt(CYGNUM_HAL_INTERRUPT_RTC);
>    Cyg_Clock::real_time_clock = this;
> }
>
> The tick value is incremented from the DSR:
>
> void Cyg_RealTimeClock::dsr(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
>    rtc->tick( count );
>
> The period of the RTC clock is configurable from your .ecc file.
>
> Christophe
>

--
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] 7+ messages in thread

* Re: [ECOS] eCos heartbeat function handler
  2009-07-19  8:18 ` Andrew Lunn
  2009-07-19 14:07   ` Nodir Qodirov
@ 2009-08-05 11:22   ` Ormund Williams
  1 sibling, 0 replies; 7+ messages in thread
From: Ormund Williams @ 2009-08-05 11:22 UTC (permalink / raw)
  To: ecos-discuss

On Sun, 2009-07-19 at 10:18 +0200, Andrew Lunn wrote:
> > 2) Where should I specify (some assembler file...) which function to
> > call on each heartbeat?
> 
> Take a look at:
> 
> http://ecos.sourceware.org/docs-latest/user-guide/clocks-and-alarm-handlers.html
> 
> Call 
> cyg_alarm_initialize(test_alarmH, cyg_current_time()+1, 1);
> 
> and you alarm function will be called every tick.
> 
>     Andrew
> 
Hi Andrew 

Can you respond to me directly?

Thank you.
-- 
Ormund Williams
OrmLab LLC


-- 
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] 7+ messages in thread

end of thread, other threads:[~2009-08-05 11:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-19  8:08 [ECOS] eCos heartbeat function handler Nodir Qodirov
2009-07-19  8:18 ` Andrew Lunn
2009-07-19 14:07   ` Nodir Qodirov
2009-07-19 14:47     ` Christophe Coutand
2009-07-21  6:52       ` Nodir Qodirov
2009-07-21  7:27         ` Christophe Coutand
2009-08-05 11:22   ` Ormund Williams

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