EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

How to use HC12's ECT as a general purpose Timer?

Started by Uwe Arends May 18, 2005
Amr,

> I am a new member in this group. I hope to gain new knowledge and
> share my konwledge with you.
>
> I need to implement a general purpose timer on HC12 microcontroller
> and as U know it is not provided in HC12. ECT, Enhanced Capture
> Timer, is the only thing that can be used for this purpose.

not true, you also have the modulus down counter, which is part of the
ECT block but completely independent of the "main" timer.

> I have an idea to use ECT as a General Purpose Timer. This can be
> achieved by changing the value of the comparator of a channel each
> time a it finishs its period. The main disadvantage of this technique
> is that periods may be irrigular because of the adjustement of the
> comparator is depending on ISR which may ba masked or delayed!
>
> Any Suggestion or documentation describing how to achieve this?

I always use the before mentioned Modulus Down Counter when in need for
consistent timing "ticks". No reload necessary, since it has it's own
load register, browse through S12ECT16B8CV1.pdf, the ECT block user guide,
for detailed information.

hth
-uwe


Yes Edward, but I think this may delay the period of the timer
because TCx=TCx+ticks; should be placed in a certain ISR which means
that if interrupts are disabled for a certain time, no way to
readjust TCx.

What do U think?
Amr
--- In 68HC12@68HC..., "Edward Karpicz" <karpicz@a...> wrote:
> > Hi all,
> > I am a new member in this group. I hope to gain new knowledge and
> > share my konwledge with you.
> >
> > I need to implement a general purpose timer on HC12
microcontroller
> > and as U know it is not provided in HC12. ECT, Enhanced Capture
> > Timer, is the only thing that can be used for this purpose.
> >
> > I have an idea to use ECT as a General Purpose Timer. This can be
> > achieved by changing the value of the comparator of a channel each
> > time a it finishs its period. The main disadvantage of this
technique
> > is that periods may be irrigular because of the adjustement of the
> > comparator is depending on ISR which may ba masked or delayed!
>
> Instead of
>
> TCx=TCNT+ticks;
>
> use
>
> TCx=TCx+ticks; > Edward
>
> >
> > Any Suggestion or documentation describing how to achieve this?
> >
> > Thanx for your interest,
> > Amr


OK Mike, but will this provide eight different channels?

Amr
--- In 68HC12@68HC..., "Michael Elphick" <mike.elphick@d...>
wrote:
>
> On Wednesday, May 18, 2005 9:27 AM (BST),
> "Amr M. Adel" <amradel_79@h...> wrote: - > > Hi all,
> > I am a new member in this group. I hope to gain new knowledge and
> > share my konwledge with you.
> >
> > I need to implement a general purpose timer on HC12
microcontroller
> > and as U know it is not provided in HC12. ECT, Enhanced Capture
> > Timer, is the only thing that can be used for this purpose.
> >
> > I have an idea to use ECT as a General Purpose Timer. This can be
> > achieved by changing the value of the comparator of a channel each
> > time a it finishs its period. The main disadvantage of this
technique
> > is that periods may be irrigular because of the adjustement of the
> > comparator is depending on ISR which may ba masked or delayed!
> >
> > Any Suggestion or documentation describing how to achieve this?
> >
> > Thanx for your interest,
> > Amr
>
> Why not use the Real Time Interrupt (RTI), which is part of the
Clock
> and Reset Generator (CRG)? This is derived from OSCCLK via a
> divisor register. To get this to work with a seconds time-base you
may
> need a non-standard crystal frequency or an adjustment in your
> interrupt routine.
>
> Mike.




I know that modulus counter can achieve this task but for only one
channel. What if I need more than one channel, e.g. eight channels?

Thanx,
Amr
--- In 68HC12@68HC..., "Uwe Arends" <nospam@u...> wrote:
> Amr,
>
> > I am a new member in this group. I hope to gain new knowledge and
> > share my konwledge with you.
> >
> > I need to implement a general purpose timer on HC12
microcontroller
> > and as U know it is not provided in HC12. ECT, Enhanced Capture
> > Timer, is the only thing that can be used for this purpose.
>
> not true, you also have the modulus down counter, which is part of
the
> ECT block but completely independent of the "main" timer.
>
> > I have an idea to use ECT as a General Purpose Timer. This can be
> > achieved by changing the value of the comparator of a channel each
> > time a it finishs its period. The main disadvantage of this
technique
> > is that periods may be irrigular because of the adjustement of the
> > comparator is depending on ISR which may ba masked or delayed!
> >
> > Any Suggestion or documentation describing how to achieve this?
>
> I always use the before mentioned Modulus Down Counter when in need
for
> consistent timing "ticks". No reload necessary, since it has it's
own
> load register, browse through S12ECT16B8CV1.pdf, the ECT block user
guide,
> for detailed information.
>
> hth
> -uwe


Amr,

> I know that modulus counter can achieve this task but for only one
> channel. What if I need more than one channel, e.g. eight channels?

well, I think I didn't and still don't understamd what you mean by
general purpose timer then!

-uwe


> Yes Edward, but I think this may delay the period of the timer
> because TCx=TCx+ticks; should be placed in a certain ISR which means
> that if interrupts are disabled for a certain time, no way to
> readjust TCx.

No. Whatever you meant, dedicated hardware timer is no better than single
ECT channel. That's my IMO. TCx+=ticks is fine to generate jitterless
periods! TCx=TCNT+ticks isn't because of interrupts.

Edward >
> What do U think?
> Amr >
> --- In 68HC12@68HC..., "Edward Karpicz" <karpicz@a...> wrote:
>> > Hi all,
>> > I am a new member in this group. I hope to gain new knowledge and
>> > share my konwledge with you.
>> >
>> > I need to implement a general purpose timer on HC12
> microcontroller
>> > and as U know it is not provided in HC12. ECT, Enhanced Capture
>> > Timer, is the only thing that can be used for this purpose.
>> >
>> > I have an idea to use ECT as a General Purpose Timer. This can be
>> > achieved by changing the value of the comparator of a channel each
>> > time a it finishs its period. The main disadvantage of this
> technique
>> > is that periods may be irrigular because of the adjustement of the
>> > comparator is depending on ISR which may ba masked or delayed!
>>
>> Instead of
>>
>> TCx=TCNT+ticks;
>>
>> use
>>
>> TCx=TCx+ticks;
>>
>>
>> Edward
>>
>> >
>> > Any Suggestion or documentation describing how to achieve this?
>> >
>> > Thanx for your interest,
>> > Amr > Yahoo! Groups Links


--- In 68HC12@68HC..., "Uwe Arends" <nospam@u...> wrote:
> Amr,
>
> > I know that modulus counter can achieve this task but for only one
> > channel. What if I need more than one channel, e.g. eight channels?
>
> well, I think I didn't and still don't understamd what you mean by
> general purpose timer then!
>
> -uwe

Sorry for being vague. I mean that how can I setup the eight channels
of the ECT as continous timers? I dont want to use one shot timers I
need them continous. Is it now clear?

Thanx for your patience,
Amr


Amr,

From the expression 'general purpose timer', it is
is difficult to know what it is you are after.

The RTI can operate several timers, but what
period and resolution do you require? Are you
timing external events etc.?

Mike.

> OK Mike, but will this provide eight different channels?
>
> Amr
> --- In 68HC12@68HC..., "Michael Elphick" <mike.elphick@d...>
> wrote:
>>
>> On Wednesday, May 18, 2005 9:27 AM (BST),
>> "Amr M. Adel" <amradel_79@h...> wrote: -
>>
>>
>> > Hi all,
>> > I am a new member in this group. I hope to gain new knowledge and
>> > share my konwledge with you.
>> >
>> > I need to implement a general purpose timer on HC12
> microcontroller
>> > and as U know it is not provided in HC12. ECT, Enhanced Capture
>> > Timer, is the only thing that can be used for this purpose.
>> >
>> > I have an idea to use ECT as a General Purpose Timer. This can be
>> > achieved by changing the value of the comparator of a channel each
>> > time a it finishs its period. The main disadvantage of this
> technique
>> > is that periods may be irrigular because of the adjustement of the
>> > comparator is depending on ISR which may ba masked or delayed!
>> >
>> > Any Suggestion or documentation describing how to achieve this?
>> >
>> > Thanx for your interest,
>> > Amr
>>
>> Why not use the Real Time Interrupt (RTI), which is part of the
> Clock
>> and Reset Generator (CRG)? This is derived from OSCCLK via a
>> divisor register. To get this to work with a seconds time-base you
> may
>> need a non-standard crystal frequency or an adjustment in your
>> interrupt routine.
>>
>> Mike. >
>
> Yahoo! Groups Links




Amr,

> > > I know that modulus counter can achieve this task but for only one
> > > channel. What if I need more than one channel, e.g. eight channels?
> >
> > well, I think I didn't and still don't understamd what you mean by
> > general purpose timer then!
> >
>
> Sorry for being vague. I mean that how can I setup the eight channels
> of the ECT as continous timers? I dont want to use one shot timers I
> need them continous. Is it now clear?

With eight channels, do you mean eight more or less independent timebases
causing interrupts, triggering actions? What are you trying to achieve?

> Thanx for your patience,

No patience involved as of yet :o)

-uwe


--- In 68HC12@68HC..., "Uwe Arends" <nospam@u...> wrote:
> Amr,
>
> > > > I know that modulus counter can achieve this task but for
only one
> > > > channel. What if I need more than one channel, e.g. eight
channels?
> > >
> > > well, I think I didn\'t and still don\'t understamd what you mean
by
> > > general purpose timer then!
> > >
> >
> > Sorry for being vague. I mean that how can I setup the eight
channels
> > of the ECT as continous timers? I dont want to use one shot
timers I
> > need them continous. Is it now clear?
>
> With eight channels, do you mean eight more or less independent
timebases
> causing interrupts, triggering actions? What are you trying to
achieve?
In Breif, I want to generate eight independent timers. Each timer is
working in continous mode which means it generates periodic
interrupt. That\'s All,
Thanx,
Amr
>
> > Thanx for your patience,
>
> No patience involved as of yet :o)
>
> -uwe



The 2024 Embedded Online Conference