This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Additional Clock on AEB
- To: ecos-discuss at sourceware dot cygnus dot com
- Subject: [ECOS] Additional Clock on AEB
- From: k e <ndgipper at yahoo dot com>
- Date: Tue, 22 Feb 2000 10:38:29 -0800 (PST)
> Question about additional clock on AEB.
> I'm trying to create a second clock that will tick
> every 20ms.
> I'd like this clock to attach to an alarm. Below,
> I've modified the
> appropriate portion of the simple-alarm.c example
> program
> to have an alarm every .4 sec. I've also added a
> print to
> the loop that reports the current state of the alarm
> counter.
> The alarm counter that I think I've attached to the
> new clock
> is not clicking. The reported value is always 0.
> Am I missing something about actually STARTING the
> new clock.
> It seems like the clock never gets going. Or if it
> does,
> the alarm counter isn't clicking.
> OR is isn't something possibly as nasty as I can't
> have a clock
> that ticks FASTER than the system clock.... If so,
> that's ugly.
> Isn't the AEB capable of having more than one clock
> going?
> Here's the modified protion of the example
> program....
>
>
> /* alarm_prog() is a thread which sets up an alarm
> which is then
> handled by test_alarm_func() */
> static void alarm_prog(cyg_addrword_t data)
> {
>
> cyg_clock clock1; // the additional
> clock
> cyg_resolution_t res_clock1; // the resolution
> for the additional clock
> cyg_handle_t hclock1; // handle to the
> additional clock
> cyg_handle_t test_counterH, system_clockH,
> test_alarmH;
> cyg_tick_count_t ticks;
> cyg_alarm test_alarm;
> unsigned how_many_alarms = 0, prev_alarms = 0,
> tmp_how_many;
>
>
> // this creates the additional clock with 20ms
> freq.
> res_clock1.dividend=20000000;
> res_clock1.divisor=1;
> cyg_clock_create(res_clock1, &hclock1, &clock1);
>
> cyg_clock_to_counter(hclock1, &test_counterH); //
> point the counter to the new clock
> cyg_alarm_create(test_counterH, test_alarm_func,
> (cyg_addrword_t)
> &how_many_alarms,
> &test_alarmH, &test_alarm);
> //have it fire ever .4 sec, right???
> cyg_alarm_initialize(test_alarmH,
> cyg_counter_current_value(test_counterH)+20, 20);
>
> /* get in a loop in which we read the current time
> and
> print it out, just to have something scrolling
> by */
> for (;;) {
> ticks = cyg_current_time();
> printf("Time is %llu\n\r", ticks);
> printf("Clock counter is
> %lld\n\r",cyg_counter_current_value(test_counterH));
> // for debugging
> /* note that we must lock access to
> how_many_alarms, since the
> alarm handler might change it. this involves
> using the
> annoying temporary variable tmp_how_many so
> that I can keep the
> critical region short */
> cyg_scheduler_lock();
> tmp_how_many = how_many_alarms;
> cyg_scheduler_unlock();
> if (prev_alarms != tmp_how_many) {
> printf(" ---> alarm calls so far: %u\n\r",
> tmp_how_many);
> prev_alarms = tmp_how_many;
> }
> cyg_thread_delay(30);
> }
> }
>
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com