From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Andrey Nechypurenko <andreynech@domain.hid>
Cc: Xenomai help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Jitter while generating PWMs with GPIO from RTDM driver
Date: Mon, 23 Apr 2012 14:51:36 +0200 [thread overview]
Message-ID: <4F955058.6080004@domain.hid> (raw)
In-Reply-To: <CAOiXNkDKRpQKjtvC-H1YsJtHkNWYcWTUEKPqfYv0HQ_=SRHGCw@domain.hid>
On 04/23/2012 02:35 PM, Andrey Nechypurenko wrote:
>>> retval = rtdm_task_init(&pwm_task[i], // there is currently only one
>>> element in this array
>>> "pwm-task",
>>> pwm_task_proc,
>>> 0,
>>> RTDM_TASK_HIGHEST_PRIORITY,
>>> 20000000); // 20ms period
>>
>> Do not use a thread, use a timer.
>
> So you mean instead of starting periodic task with rtdm_task_init() it
> is better use timer functions to trigger pin toggling piece of code?
> Could you please elaborate on it a little? I thought that
> rtdm_task_sleep() and rtdm_task_wait_period() are using timers
> internally to wake up the thread at the right moment. Is not they?
Yes, but once the timer is woken up, a context switch is needed to wake
up the thread, this adds time.
>
> Is not it a kind of work-around you suggesting? If there are some
> problems which led to the imprecise timing of the sleep/wait functions
> mentioned above, then, if technically possible, it would be better to
> fix them instead of working around this behavior.
No, the time it takes to switch context between threads is unavoidable.
So, if you want to avoid it, you have to use a timer (rtdm_timer_init),
note that it is really common in RTOS interfaces to offer a timer API,
this is not a workaround at all.
The other alternative I describe in my last mail, that is, using a
dedicated hardware timer with its own irq handler, is a bit more of a
workaround, but still not uncommon in the RTOS world.
--
Gilles.
next prev parent reply other threads:[~2012-04-23 12:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 11:56 [Xenomai-help] Jitter while generating PWMs with GPIO from RTDM driver Andrey Nechypurenko
2012-04-23 12:27 ` Gilles Chanteperdrix
2012-04-23 12:35 ` Andrey Nechypurenko
2012-04-23 12:51 ` Gilles Chanteperdrix [this message]
2012-04-23 12:57 ` Andrey Nechypurenko
2012-04-23 13:15 ` Philippe Gerum
2013-07-22 16:52 ` [Xenomai] " Christoph
2013-07-22 20:51 ` Andrey Nechypurenko
2012-04-23 12:59 ` [Xenomai-help] " Gilles Chanteperdrix
2012-04-23 13:05 ` Andrey Nechypurenko
2012-04-23 12:44 ` Gilles Chanteperdrix
2012-04-23 13:14 ` Wolfgang Grandegger
2012-04-23 13:25 ` Andrey Nechypurenko
2012-04-23 13:37 ` Wolfgang Grandegger
[not found] <CAOiXNkD+-yANz15W_cnD9QLjyGH7LUT-Pf8LEJHqx4Kh24pL+g@mail.gmail.com>
[not found] ` <4F954ABE.20508@xenomai.org>
[not found] ` <CAOiXNkDKRpQKjtvC-H1YsJtHkNWYcWTUEKPqfYv0HQ_=SRHGCw@mail.gmail.com>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F955058.6080004@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=andreynech@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.