Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
RE: How to use HC12's ECT as a general purpose Timer? - Mark Wyman - May 18 14:49:00 2005
Ok, I am going to take a leap here based on the other postings:
Set up an accurate single timer interrupt, at your least common denominator
of time slices, say 10mS. Make sure it is nice and jitterless by testing an
I/O pin.
Then in the interrupt, handle several count-down to zero counters:
__interrupt void timerInterrupt(void) {
//Update timer registers here
critical10mSTask(); //The least common
denominator task that must be executed accurately and constantly
if (countdown1) countdown1--;
if (countdown2) countdown2--;
if (countdown3) countdown3--;
//clear mask
}
In your main routine:
While (TRUE) {
If(!countdown1) {
countdown1 = 1000; //Value for next execution
x interrupt rate, in this case 1000 x 10mS
ExecuteTask1();
}
If(!countdown2) {
dountdown2 = 5000; //Value for next execution
x interrupt rate
ExecuteTask2();
}
}
While the above example doesn't guarantee that tasks execute at just the
right time if any task takes longer than your minimum time, they will always
execute, but is great for non-critical timing of tasks since it is very easy
to manage.
If you need better time accuracy, execute tasks right in the interrupt:
__interrupt void timerInterrupt(void) {
//Update timer registers here
critical10mSTask(); //The least common
denominator task that must be executed accurately
if (countdown1) countdown1--; //Decrement all individual
timers first
if (countdown2) countdown2--;
if (countdown3) countdown3--;
if (!countdown1) { //Execute all tasks
that have hit zero.
countdown1 = 1000;
executeTask1();
}
if (!countdown2) {
countDown2 = 5000;
executeTask2();
}
//clear mask
}
However again the sun all of your tasks must execute faster than the minimum
time, in this case 10mS, or else you will get a cascade timing error.
Otherwise make sure and stagger the timers so only one task may execute in
any given interrupt hit.
While this is very simplistic, it shows there are many ways to tackle
multiple timers with a single timer interrupt.
Some of the drawbacks are that executeTask1() has highest priority and it's
execution time will impact when executeTask2() will be able to execute. Say
task1 takes 5-7mS, task 2 will begin to execute 5-7mS+ a little after the
interrupt was hit so it's execution may vary from 0-7mS from the initial
interrupt.
This is unavoidable since you only have a single core processor. You can
increase accuracy of the start of your routines by multi-tasking, but then
you run into the problems of unpredictable execution rates of routines, and
the added overhead of task switching.
Look at some RTOS's out there for more info on this subject, I doubt they
use more than 2 times for handling many tasks at a time.
-Mark W
_____
From: 68HC12@68HC... [mailto:68HC12@68HC...] On Behalf Of
Amr M. Adel
Sent: Wednesday, May 18, 2005 4:27 AM
To: 68HC12@68HC...
Subject: [68HC12] How to use HC12's ECT as a general purpose Timer?
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
_____
> Terms of Service.
[Non-text portions of this message have been removed]

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
Re: How to use HC12's ECT as a general purpose Timer? - Amr M. Adel - May 22 2:54:00 2005
Mark and Robmilne,
sorry for the late response. I didn't have an access to the net in
the prev. days. I will study your replies and will send U my feedback.
Thanx,
Amr
--- In 68HC12@68HC..., "Mark Wyman" <mark@r...> wrote:
> Ok, I am going to take a leap here based on the other postings:
>
> Set up an accurate single timer interrupt, at your least common
denominator
> of time slices, say 10mS. Make sure it is nice and jitterless by
testing an
> I/O pin.
>
> Then in the interrupt, handle several count-down to zero counters:
>
> __interrupt void timerInterrupt(void) {
>
> //Update timer registers here
>
> critical10mSTask(); //The least
common
> denominator task that must be executed accurately and constantly
>
> if (countdown1) countdown1--;
>
> if (countdown2) countdown2--;
>
> if (countdown3) countdown3--;
>
> //clear mask
>
> }
>
> In your main routine:
>
> While (TRUE) {
>
> If(!countdown1) {
>
> countdown1 = 1000; //Value for next
execution
> x interrupt rate, in this case 1000 x 10mS
>
> ExecuteTask1();
>
> }
>
> If(!countdown2) {
>
> dountdown2 = 5000; //Value for next
execution
> x interrupt rate
>
> ExecuteTask2();
>
> }
>
> }
>
> While the above example doesn't guarantee that tasks execute at
just the
> right time if any task takes longer than your minimum time, they
will always
> execute, but is great for non-critical timing of tasks since it is
very easy
> to manage.
>
> If you need better time accuracy, execute tasks right in the
interrupt:
>
> __interrupt void timerInterrupt(void) {
>
> //Update timer registers here
>
> critical10mSTask(); //The least
common
> denominator task that must be executed accurately
>
> if (countdown1) countdown1--; //Decrement all
individual
> timers first
>
> if (countdown2) countdown2--;
>
> if (countdown3) countdown3--;
>
> if (!countdown1) { //Execute all
tasks
> that have hit zero.
>
> countdown1 = 1000;
>
> executeTask1();
>
> }
>
> if (!countdown2) {
>
> countDown2 = 5000;
>
> executeTask2();
>
> }
> //clear mask
>
> }
>
> However again the sun all of your tasks must execute faster than
the minimum
> time, in this case 10mS, or else you will get a cascade timing
error.
> Otherwise make sure and stagger the timers so only one task may
execute in
> any given interrupt hit.
>
> While this is very simplistic, it shows there are many ways to
tackle
> multiple timers with a single timer interrupt.
>
> Some of the drawbacks are that executeTask1() has highest priority
and it's
> execution time will impact when executeTask2() will be able to
execute. Say
> task1 takes 5-7mS, task 2 will begin to execute 5-7mS+ a little
after the
> interrupt was hit so it's execution may vary from 0-7mS from the
initial
> interrupt.
>
> This is unavoidable since you only have a single core processor.
You can
> increase accuracy of the start of your routines by multi-tasking,
but then
> you run into the problems of unpredictable execution rates of
routines, and
> the added overhead of task switching.
>
> Look at some RTOS's out there for more info on this subject, I
doubt they
> use more than 2 times for handling many tasks at a time.
>
> -Mark W
>
> _____
>
> From: 68HC12@68HC... [mailto:68HC12@68HC...] On
Behalf Of
> Amr M. Adel
> Sent: Wednesday, May 18, 2005 4:27 AM
> To: 68HC12@68HC...
> Subject: [68HC12] How to use HC12's ECT as a general purpose Timer?
>
> 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
>
> _____
>
> > Terms of Service.
>
> [Non-text portions of this message have been removed]
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com ) Codewarrior for ST7 - dwarkanath avarur - May 25 5:17:00 2005
Hello
Will Codewarrior is available for ST7 microcontroller.
Currently i have codewarrior for HC12 with BDM. If i
want to have codewarrior for ST7, what are all i shud
look upon.
Will codewarrior supports Cosmic compiler in its IDE.
Your response will be helpful
Thanks
__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )
RE: Codewarrior for ST7 - Liechty Ronald-RAT109 - May 25 12:03:00 2005
dwarkanath avarur wrote:
> Will Codewarrior is available for ST7 microcontroller.
> Currently i have codewarrior for HC12 with BDM. If i
> want to have codewarrior for ST7, what are all i shud
> look upon.
In order to purchase CodeWarrior for ST7 you need to contact sales it is not available for
direct purchase online. You must purchase with purchase order.
sales@sale...
Thanks for your interest.
Ron

(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )