From: Nick Garnett <nickg@ecoscentric.com>
To: Jim Seymour <ecosjim@cipher.com>
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] CDL define_proc: Unable to put "extern" in an include files
Date: Fri, 01 Jun 2007 08:54:00 -0000 [thread overview]
Message-ID: <m3vee8hx6z.fsf@xl5.calivar.com> (raw)
In-Reply-To: <465DBB45.3070802@cipher.com>
Jim Seymour <ecosjim@cipher.com> writes:
>
> What I'm trying to do is allow for our system clock speed to be a
> run-time variable, instead of a fixed constant. This means that the
> #define's that get generated for CYGNUM_RTC_PERIOD (and the like) will
> refer to a global variable. Without an "extern" statement, these
> references will cause a compiler error.
There are other ways to achieve this.
The way I have done this in the past is not to make CYGNUM_RTC_PERIOD
variable. Too much code assumes that this value is a constant; it uses
its value on startup to calculate some scaling factors, or whatever,
and then doesn't read it again. So even if CYGNUM_RTC_PERIOD were to
vary, the original derived values would still be used.
Instead, where I want to run the system at different clock speeds I
express CYGNUM_RTC_PERIOD is terms of a fictional fixed rate clock;
usually around 1MHz, but you can go as low as 1KHz if you want. Then,
in HAL_CLOCK_INITIALIZE(), I calculate the real clock period using the
current system clock rate. The selected period is saved in the HAL, so
when I change the system clock rate I can recalculate the real period
(just recalling HAL_CLOCK_INITIALIZE() does the trick usually).
Obviously HAL_CLOCK_READ() also needs to do some arithmetic to
translate system clock ticks back into ticks of the fictional clock.
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
prev parent reply other threads:[~2007-06-01 8:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 18:04 Jim Seymour
2007-05-30 19:02 ` Andrew Lunn
2007-05-31 19:43 ` Jim Seymour
2007-05-31 21:44 ` Andrew Lunn
2007-05-31 22:20 ` Jim Seymour
2007-06-01 8:54 ` Nick Garnett [this message]
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=m3vee8hx6z.fsf@xl5.calivar.com \
--to=nickg@ecoscentric.com \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=ecosjim@cipher.com \
/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 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).