This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions,
flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.
I need some help to make a part of a largish program pre-emptive - rmoore007ri - May 12 14:19:49 2009
This is a realtime data collection problem. Running on an OP7200. It drives an optical
system and an observer pushes some buttons to change what they see. (or report what they
see.)
Part of what they see is two LEDs alternating with each other in square wave fashion at a
rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
That part is in a simple costate:
costate flickerout always_on // create flicker here
{
waitfor(DelayMs(halfperiod));
digOut (ch1, 0); // LED1 off
digOut (ch2, 1); // LED2 on
waitfor(DelayMs(halfperiod));
digOut (ch1, 1); // LED1 on
digOut (ch2, 0); // LED2 off
}
Of course, early on, before the code got from 2 KB to 88 KB, there was NO perceptible
"jiggle" as the observer pressed various pushbuttons tied to digital inputs. But now there
are clear blips in this otherwise very clean looking signal.
I've been doing a lot of reading. It looks like I need to make this part of the code run
pre-emtively. The need is for this:
- a square wave running from 5 to 35 Hz.
- the half-period needs to be set from outside the pre-emtive code.
I am having trouble getting my head around this. The SLICE statement looked like the way
to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
I'd appreciate ideas. Anyone want a little work ??
thanks
bob moore
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: I need some help to make a part of a largish program pre-emptive - Scott Henion - May 12 14:32:47 2009
rmoore007ri wrote:
> This is a realtime data collection problem. Running on an OP7200. It drives an optical
system and an observer pushes some buttons to change what they see. (or report what they
see.)
>
> Part of what they see is two LEDs alternating with each other in square wave fashion at
a rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
>
> That part is in a simple costate:
>
> costate flickerout always_on // create flicker here
> {
> waitfor(DelayMs(halfperiod));
> digOut (ch1, 0); // LED1 off
> digOut (ch2, 1); // LED2 on
> waitfor(DelayMs(halfperiod));
> digOut (ch1, 1); // LED1 on
> digOut (ch2, 0); // LED2 off
> }
>
> Of course, early on, before the code got from 2 KB to 88 KB, there was NO perceptible
"jiggle" as the observer pressed various pushbuttons tied to digital inputs. But now there
are clear blips in this otherwise very clean looking signal.
>
> I've been doing a lot of reading. It looks like I need to make this part of the code run
pre-emtively. The need is for this:
>
> - a square wave running from 5 to 35 Hz.
> - the half-period needs to be set from outside the pre-emtive code.
>
> I am having trouble getting my head around this. The SLICE statement looked like the way
to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
>
> I'd appreciate ideas. Anyone want a little work ??
>
> thanks
>
> bob moore
>
Make it run from an interrupt at 5ms. You can use timer B to generate
the int, I have the lib in my free libs page:
http://shdesigns.org/rabbit/freelibs.shtml
halfperiod would be the # of ms, 100 for 5hz, 15 for 35hz (approx)
void TimerBroutine(void)
{
static int ledstate,ledctr;
#GLOBAL_INIT{state=0; ledctr=0;};
ledctr-=5; // we run every 5ms
if (ledcttr>0)
return;
ledstate=!ledstate;
digOut (ch1, ledstate); // LED1 off
digOut (ch2, !ledstate); // LED2 on
}
--
------------------------------------------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------------------------------------------
today's fortune
We are all aware that the senses can be deceived, the eyes fooled.
But how can we be sure our senses are not being deceived at any
particular time, or even all the time? Might I just be a brain in
a tank somewhere, tricked all my life into believing in the events
of this world by some insane computer? And does my life gain or lose
meaning based on my reaction to such solipsism?
-- Project PYRRHO, Specimen 46, Vat 7
Activity Recorded M.Y. 2302.22467
TERMINATION OF SPECIMEN ADVISED
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
RE: I need some help to make a part of a largish program pre-emptive - "Moore, Robert" - May 13 8:38:39 2009
Hi Scott,
Much thanks. I've been looking at your TimerB already. With a 5 msec interrupt the
granularity would be much too coarse for my needs. (The half period would be 5 or 10 or 15
msec.) I need an output selectable by the user at one Hz intervals from 1 to 35 Hz. I'll
look at clocking it at a higher rate.
My background is not with embedded systems. But with counter/timer chips like the AMD 9513
or the Intel 8254. Which come with dozens (and dozens) of pages of documentation. I think
I just expected to find a timer I could preset with a count (say 1400) and count down at
(say) 1 MHz . . . At overflow, grab the interrupt and configure it to reload and preset
again . . .
The OP7200 specs say it has "Five 8-bit timers (4 cascadable from the first) and one
10-bit timer with 2 match registers" which pretty much led me to think that Rabbit
actually would make it easy to use this hardware. And this bit would be a breeze. With
libraries and all that good stuff. Shucks, in the OP7200 manual index there is not even an
entry for "clock" or "timer" . . .
Thanks for all you are doing in this area. And all the support you obviously give
others.
regards
bob moore
________________________________
From: r...@yahoogroups.com on behalf of Scott Henion
Sent: Tue 5/12/2009 2:32 PM
To: r...@yahoogroups.com
Subject: Re: [rabbit-semi] I need some help to make a part of a largish program
pre-emptive
rmoore007ri wrote:
> This is a realtime data collection problem. Running on an OP7200. It drives an optical
system and an observer pushes some buttons to change what they see. (or report what they
see.)
>
> Part of what they see is two LEDs alternating with each other in square wave fashion at
a rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
>
> That part is in a simple costate:
>
> costate flickerout always_on // create flicker here
> {
> waitfor(DelayMs(halfperiod));
> digOut (ch1, 0); // LED1 off
> digOut (ch2, 1); // LED2 on
> waitfor(DelayMs(halfperiod));
> digOut (ch1, 1); // LED1 on
> digOut (ch2, 0); // LED2 off
> }
>
> Of course, early on, before the code got from 2 KB to 88 KB, there was NO perceptible
"jiggle" as the observer pressed various pushbuttons tied to digital inputs. But now there
are clear blips in this otherwise very clean looking signal.
>
> I've been doing a lot of reading. It looks like I need to make this part of the code run
pre-emtively. The need is for this:
>
> - a square wave running from 5 to 35 Hz.
> - the half-period needs to be set from outside the pre-emtive code.
>
> I am having trouble getting my head around this. The SLICE statement looked like the way
to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
>
> I'd appreciate ideas. Anyone want a little work ??
>
> thanks
>
> bob moore
>
Make it run from an interrupt at 5ms. You can use timer B to generate
the int, I have the lib in my free libs page:
http://shdesigns.org/rabbit/freelibs.shtml
halfperiod would be the # of ms, 100 for 5hz, 15 for 35hz (approx)
void TimerBroutine(void)
{
static int ledstate,ledctr;
#GLOBAL_INIT{state=0; ledctr=0;};
ledctr-=5; // we run every 5ms
if (ledcttr>0)
return;
ledstate=!ledstate;
digOut (ch1, ledstate); // LED1 off
digOut (ch2, !ledstate); // LED2 on
}
--
------------------------------------------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org
|
------------------------------------------
today's fortune
We are all aware that the senses can be deceived, the eyes fooled.
But how can we be sure our senses are not being deceived at any
particular time, or even all the time? Might I just be a brain in
a tank somewhere, tricked all my life into believing in the events
of this world by some insane computer? And does my life gain or lose
meaning based on my reaction to such solipsism?
-- Project PYRRHO, Specimen 46, Vat 7
Activity Recorded M.Y. 2302.22467
TERMINATION OF SPECIMEN ADVISED
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: I need some help to make a part of a largish program pre-emptive - Jon - May 15 8:01:44 2009
You probably won't find this in the OP7200 manual. Rabbit has a lot of manuals, and one
of the problems is figuring out which one to consult. My suggestion is to search BOTH the
DC manual and the microprocessor manual for more info. I believe that there is also a
timerb demo in the samples folder which might be good for a simple how-to demo. And there
might also be a tech note or white paper regarding this. I am away from my work computer,
so I can't look myself.
I'm running a timer interrupt in the 1k-10k / second range with no problem; it happens
exactly as intended. Setting it up is similar to what you describe, except I think that
there is both a divisor and a counter to get a wider range of period. Your interrupt can
add a third (int or long) counter to reset to various values to get the final long period
event.
This is soooo much better than the co-state; the times will be very consistent. Co-state
is handy if you are doing a couple simple somethings that are not very time-critical.
Enjy and let us know how it works out for you.
Jon
--- In r...@yahoogroups.com, "Moore, Robert"
wrote:
>
> Hi Scott,
>
> Much thanks. I've been looking at your TimerB already. With a 5 msec interrupt the
granularity would be much too coarse for my needs. (The half period would be 5 or 10 or 15
msec.) I need an output selectable by the user at one Hz intervals from 1 to 35 Hz. I'll
look at clocking it at a higher rate.
>
> My background is not with embedded systems. But with counter/timer chips like the AMD
9513 or the Intel 8254. Which come with dozens (and dozens) of pages of documentation. I
think I just expected to find a timer I could preset with a count (say 1400) and count
down at (say) 1 MHz . . . At overflow, grab the interrupt and configure it to reload and
preset again . . .
>
> The OP7200 specs say it has "Five 8-bit timers (4 cascadable from the first) and one
10-bit timer with 2 match registers" which pretty much led me to think that Rabbit
actually would make it easy to use this hardware. And this bit would be a breeze. With
libraries and all that good stuff. Shucks, in the OP7200 manual index there is not even an
entry for "clock" or "timer" . . .
>
> Thanks for all you are doing in this area. And all the support you obviously give
others.
>
> regards
>
> bob moore
>
>
>
> ________________________________
>
> From: r...@yahoogroups.com on behalf of Scott Henion
> Sent: Tue 5/12/2009 2:32 PM
> To: r...@yahoogroups.com
> Subject: Re: [rabbit-semi] I need some help to make a part of a largish program
pre-emptive
>
> rmoore007ri wrote:
> > This is a realtime data collection problem. Running on an OP7200. It drives an optical
system and an observer pushes some buttons to change what they see. (or report what they
see.)
> >
> > Part of what they see is two LEDs alternating with each other in square wave fashion
at a rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
> >
> > That part is in a simple costate:
> >
> > costate flickerout always_on // create flicker here
> > {
> > waitfor(DelayMs(halfperiod));
> > digOut (ch1, 0); // LED1 off
> > digOut (ch2, 1); // LED2 on
> > waitfor(DelayMs(halfperiod));
> > digOut (ch1, 1); // LED1 on
> > digOut (ch2, 0); // LED2 off
> > }
> >
> > Of course, early on, before the code got from 2 KB to 88 KB, there was NO perceptible
"jiggle" as the observer pressed various pushbuttons tied to digital inputs. But now there
are clear blips in this otherwise very clean looking signal.
> >
> > I've been doing a lot of reading. It looks like I need to make this part of the code
run pre-emtively. The need is for this:
> >
> > - a square wave running from 5 to 35 Hz.
> > - the half-period needs to be set from outside the pre-emtive code.
> >
> > I am having trouble getting my head around this. The SLICE statement looked like the
way to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
> >
> > I'd appreciate ideas. Anyone want a little work ??
> >
> > thanks
> >
> > bob moore
> >
>
> Make it run from an interrupt at 5ms. You can use timer B to generate
> the int, I have the lib in my free libs page:
>
> http://shdesigns.org/rabbit/freelibs.shtml
>
> halfperiod would be the # of ms, 100 for 5hz, 15 for 35hz (approx)
>
> void TimerBroutine(void)
> {
> static int ledstate,ledctr;
> #GLOBAL_INIT{state=0; ledctr=0;};
> ledctr-=5; // we run every 5ms
> if (ledcttr>0)
> return;
> ledstate=!ledstate;
>
> digOut (ch1, ledstate); // LED1 off
> digOut (ch2, !ledstate); // LED2 on
>
> }
> --
> ------------------------------------------
> | Scott G. Henion| shenion@... |
> | Consultant | Stone Mountain, GA |
> | SHDesigns http://www.shdesigns.org |
> ------------------------------------------
>
> today's fortune
> We are all aware that the senses can be deceived, the eyes fooled.
> But how can we be sure our senses are not being deceived at any
> particular time, or even all the time? Might I just be a brain in
> a tank somewhere, tricked all my life into believing in the events
> of this world by some insane computer? And does my life gain or lose
> meaning based on my reaction to such solipsism?
>
> -- Project PYRRHO, Specimen 46, Vat 7
> Activity Recorded M.Y. 2302.22467
> TERMINATION OF SPECIMEN ADVISED
>
> ------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )RE: Re: I need some help to make a part of a largish program pre-emptive - "Moore, Robert" - May 15 17:17:59 2009
thanks Jon
could we correspond off-list about his topic.
thanks
bob moore
R...@brown.edu
________________________________
From: r...@yahoogroups.com on behalf of Jon
Sent: Fri 5/15/2009 8:01 AM
To: r...@yahoogroups.com
Subject: [rabbit-semi] Re: I need some help to make a part of a largish program
pre-emptive
You probably won't find this in the OP7200 manual. Rabbit has a lot of manuals, and one
of the problems is figuring out which one to consult. My suggestion is to search BOTH the
DC manual and the microprocessor manual for more info. I believe that there is also a
timerb demo in the samples folder which might be good for a simple how-to demo. And there
might also be a tech note or white paper regarding this. I am away from my work computer,
so I can't look myself.
I'm running a timer interrupt in the 1k-10k / second range with no problem; it happens
exactly as intended. Setting it up is similar to what you describe, except I think that
there is both a divisor and a counter to get a wider range of period. Your interrupt can
add a third (int or long) counter to reset to various values to get the final long period
event.
This is soooo much better than the co-state; the times will be very consistent. Co-state
is handy if you are doing a couple simple somethings that are not very time-critical.
Enjy and let us know how it works out for you.
Jon
--- In r...@yahoogroups.com, "Moore, Robert"
wrote:
>
> Hi Scott,
>
> Much thanks. I've been looking at your TimerB already. With a 5 msec interrupt the
granularity would be much too coarse for my needs. (The half period would be 5 or 10 or 15
msec.) I need an output selectable by the user at one Hz intervals from 1 to 35 Hz. I'll
look at clocking it at a higher rate.
>
> My background is not with embedded systems. But with counter/timer chips like the AMD
9513 or the Intel 8254. Which come with dozens (and dozens) of pages of documentation. I
think I just expected to find a timer I could preset with a count (say 1400) and count
down at (say) 1 MHz . . . At overflow, grab the interrupt and configure it to reload and
preset again . . .
>
> The OP7200 specs say it has "Five 8-bit timers (4 cascadable from the first) and one
10-bit timer with 2 match registers" which pretty much led me to think that Rabbit
actually would make it easy to use this hardware. And this bit would be a breeze. With
libraries and all that good stuff. Shucks, in the OP7200 manual index there is not even an
entry for "clock" or "timer" . . .
>
> Thanks for all you are doing in this area. And all the support you obviously give
others.
>
> regards
>
> bob moore
>
> ________________________________
>
> From: r...@yahoogroups.com on behalf of Scott Henion
> Sent: Tue 5/12/2009 2:32 PM
> To: r...@yahoogroups.com
> Subject: Re: [rabbit-semi] I need some help to make a part of a largish program
pre-emptive
>
> rmoore007ri wrote:
> > This is a realtime data collection problem. Running on an OP7200. It drives an optical
system and an observer pushes some buttons to change what they see. (or report what they
see.)
> >
> > Part of what they see is two LEDs alternating with each other in square wave fashion
at a rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
> >
> > That part is in a simple costate:
> >
> > costate flickerout always_on // create flicker here
> > {
> > waitfor(DelayMs(halfperiod));
> > digOut (ch1, 0); // LED1 off
> > digOut (ch2, 1); // LED2 on
> > waitfor(DelayMs(halfperiod));
> > digOut (ch1, 1); // LED1 on
> > digOut (ch2, 0); // LED2 off
> > }
> >
> > Of course, early on, before the code got from 2 KB to 88 KB, there was NO perceptible
"jiggle" as the observer pressed various pushbuttons tied to digital inputs. But now there
are clear blips in this otherwise very clean looking signal.
> >
> > I've been doing a lot of reading. It looks like I need to make this part of the code
run pre-emtively. The need is for this:
> >
> > - a square wave running from 5 to 35 Hz.
> > - the half-period needs to be set from outside the pre-emtive code.
> >
> > I am having trouble getting my head around this. The SLICE statement looked like the
way to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
> >
> > I'd appreciate ideas. Anyone want a little work ??
> >
> > thanks
> >
> > bob moore
> > Make it run from an interrupt at 5ms. You can use timer B to generate
> the int, I have the lib in my free libs page:
>
> http://shdesigns.org/rabbit/freelibs.shtml
>
> halfperiod would be the # of ms, 100 for 5hz, 15 for 35hz (approx)
>
> void TimerBroutine(void)
> {
> static int ledstate,ledctr;
> #GLOBAL_INIT{state=0; ledctr=0;};
> ledctr-=5; // we run every 5ms
> if (ledcttr>0)
> return;
> ledstate=!ledstate;
>
> digOut (ch1, ledstate); // LED1 off
> digOut (ch2, !ledstate); // LED2 on
>
> }
> --
> ------------------------------------------
> | Scott G. Henion| shenion@... |
> | Consultant | Stone Mountain, GA |
> | SHDesigns http://www.shdesigns.org
|
> ------------------------------------------
>
> today's fortune
> We are all aware that the senses can be deceived, the eyes fooled.
> But how can we be sure our senses are not being deceived at any
> particular time, or even all the time? Might I just be a brain in
> a tank somewhere, tricked all my life into believing in the events
> of this world by some insane computer? And does my life gain or lose
> meaning based on my reaction to such solipsism?
>
> -- Project PYRRHO, Specimen 46, Vat 7
> Activity Recorded M.Y. 2302.22467
> TERMINATION OF SPECIMEN ADVISED
>
> ------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )RE: I need some help to make a part of a largish program pre-emptive - "Moore, Robert" - May 19 11:23:28 2009
Hi All,
My need was for a low frequency square wave from 5 to 35 Hz that would be rock stable
despite a lot of other activity from digital inputs (from user pushbuttons) and a slew of
DAC outputs changing at the other end of rabbitnet. The target is Rabbit's OP7200 . . .
Scott Henion's timerB implementation did the trick. Here is a simple (but complete)
example that steps through the frequencies. It might help some newebies.
timerB available at
http://shdesigns.org/rabbit/freelibs.shtml
regards
bob moore
__________________________________________________________
#memmap xmem // reduce root mem
#class auto //
#use "timerb.lib" // Steve Henion timerB library
//#define TIMER_INT_ENA // permits other interrupts if timerB is running
// (may be needed in your
application)
#define DIGOUTCONFIG 0xF0 // needed for OP7200 digital output channels
nodebug void msDelay(unsigned int delay)
{
unsigned long done_time;
done_time = MS_TIMER + delay;
while( (long) (MS_TIMER - done_time) < 0 );
}
nodebug root void TimerBRoutine(void)
{
static int ledstate;
static int ch0, ch1;
#GLOBAL_INIT{ch0 = 0; ch1 = 1; ledstate = 0;};
ledstate=!ledstate;
digOut (ch0, ledstate); // ch1 off/on
digOut (ch1, !ledstate); // ch2 on/off
}
#nodebug
main()
{
unsigned long halfperiod;
int lofrate;
int intpriority; // from 1 lowest to 3
highest
intpriority = 1; // MUST be "1" in MY target
app
brdInit();
digOutConfig(DIGOUTCONFIG); // configure digital outputs . . .
while (1)
{
for (lofrate = 5; lofrate < 36; lofrate++) // rates from 5 - 35 Hz
{
halfperiod = 500000/lofrate; // in usec
TimerBUninit(); // unitialize before
reinitializing
TimerBInit(halfperiod, intpriority); // at a new rate
printf("low frequency rate = %02d\n",lofrate);
msDelay(3000);
} // end for
} // end while
} // end main
____________________________________________________________________
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )Re: I need some help to make a part of a largish program pre-emptive - Jon - May 26 19:38:16 2009
The off-line thing didn't seem to work out. Perhaps a new thread is in order. But I
found the best was to dig around through the books and tinker for several days. Let me
know how worked out for you.
Jon
--- In r...@yahoogroups.com, "Moore, Robert"
wrote:
>
> thanks Jon
>
> could we correspond off-list about his topic.
>
> thanks
>
> bob moore
> Robert_Moore@...
>
> ________________________________
>
> From: r...@yahoogroups.com on behalf of Jon
> Sent: Fri 5/15/2009 8:01 AM
> To: r...@yahoogroups.com
> Subject: [rabbit-semi] Re: I need some help to make a part of a largish program
pre-emptive
>
> You probably won't find this in the OP7200 manual. Rabbit has a lot of manuals, and one
of the problems is figuring out which one to consult. My suggestion is to search BOTH the
DC manual and the microprocessor manual for more info. I believe that there is also a
timerb demo in the samples folder which might be good for a simple how-to demo. And there
might also be a tech note or white paper regarding this. I am away from my work computer,
so I can't look myself.
>
> I'm running a timer interrupt in the 1k-10k / second range with no problem; it happens
exactly as intended. Setting it up is similar to what you describe, except I think that
there is both a divisor and a counter to get a wider range of period. Your interrupt can
add a third (int or long) counter to reset to various values to get the final long period
event.
>
> This is soooo much better than the co-state; the times will be very consistent.
Co-state is handy if you are doing a couple simple somethings that are not very
time-critical.
>
> Enjy and let us know how it works out for you.
>
> Jon
>
> --- In r...@yahoogroups.com, "Moore, Robert" wrote:
> >
> > Hi Scott,
> >
> > Much thanks. I've been looking at your TimerB already. With a 5 msec interrupt the
granularity would be much too coarse for my needs. (The half period would be 5 or 10 or 15
msec.) I need an output selectable by the user at one Hz intervals from 1 to 35 Hz. I'll
look at clocking it at a higher rate.
> >
> > My background is not with embedded systems. But with counter/timer chips like the AMD
9513 or the Intel 8254. Which come with dozens (and dozens) of pages of documentation. I
think I just expected to find a timer I could preset with a count (say 1400) and count
down at (say) 1 MHz . . . At overflow, grab the interrupt and configure it to reload and
preset again . . .
> >
> > The OP7200 specs say it has "Five 8-bit timers (4 cascadable from the first) and one
10-bit timer with 2 match registers" which pretty much led me to think that Rabbit
actually would make it easy to use this hardware. And this bit would be a breeze. With
libraries and all that good stuff. Shucks, in the OP7200 manual index there is not even an
entry for "clock" or "timer" . . .
> >
> > Thanks for all you are doing in this area. And all the support you obviously give
others.
> >
> > regards
> >
> > bob moore
> >
> >
> >
> > ________________________________
> >
> > From: r...@yahoogroups.com on behalf of Scott Henion
> > Sent: Tue 5/12/2009 2:32 PM
> > To: r...@yahoogroups.com
> > Subject: Re: [rabbit-semi] I need some help to make a part of a largish program
pre-emptive
> >
> >
> >
> > rmoore007ri wrote:
> > > This is a realtime data collection problem. Running on an OP7200. It drives an
optical system and an observer pushes some buttons to change what they see. (or report
what they see.)
> > >
> > > Part of what they see is two LEDs alternating with each other in square wave fashion
at a rate from 5 to 35 Hz. So the half-period is from 14.3 msec to 100 msec.
> > >
> > > That part is in a simple costate:
> > >
> > > costate flickerout always_on // create flicker here
> > > {
> > > waitfor(DelayMs(halfperiod));
> > > digOut (ch1, 0); // LED1 off
> > > digOut (ch2, 1); // LED2 on
> > > waitfor(DelayMs(halfperiod));
> > > digOut (ch1, 1); // LED1 on
> > > digOut (ch2, 0); // LED2 off
> > > }
> > >
> > > Of course, early on, before the code got from 2 KB to 88 KB, there was NO
perceptible "jiggle" as the observer pressed various pushbuttons tied to digital inputs.
But now there are clear blips in this otherwise very clean looking signal.
> > >
> > > I've been doing a lot of reading. It looks like I need to make this part of the code
run pre-emtively. The need is for this:
> > >
> > > - a square wave running from 5 to 35 Hz.
> > > - the half-period needs to be set from outside the pre-emtive code.
> > >
> > > I am having trouble getting my head around this. The SLICE statement looked like the
way to go until I realized that it seems to gain control and prevent other things from
happening. Of course I get the uneasy feeling that I there is something I just do not
see.
> > >
> > > I'd appreciate ideas. Anyone want a little work ??
> > >
> > > thanks
> > >
> > > bob moore
> > >
> >
> > Make it run from an interrupt at 5ms. You can use timer B to generate
> > the int, I have the lib in my free libs page:
> >
> > http://shdesigns.org/rabbit/freelibs.shtml
> >
> > halfperiod would be the # of ms, 100 for 5hz, 15 for 35hz (approx)
> >
> > void TimerBroutine(void)
> > {
> > static int ledstate,ledctr;
> > #GLOBAL_INIT{state=0; ledctr=0;};
> > ledctr-=5; // we run every 5ms
> > if (ledcttr>0)
> > return;
> > ledstate=!ledstate;
> >
> > digOut (ch1, ledstate); // LED1 off
> > digOut (ch2, !ledstate); // LED2 on
> >
> > }
> >
> >
> >
> >
> >
> >
> > --
> > ------------------------------------------
> > | Scott G. Henion| shenion@ |
> > | Consultant | Stone Mountain, GA |
> > | SHDesigns http://www.shdesigns.org
|
> > ------------------------------------------
> >
> > today's fortune
> > We are all aware that the senses can be deceived, the eyes fooled.
> > But how can we be sure our senses are not being deceived at any
> > particular time, or even all the time? Might I just be a brain in
> > a tank somewhere, tricked all my life into believing in the events
> > of this world by some insane computer? And does my life gain or lose
> > meaning based on my reaction to such solipsism?
> >
> > -- Project PYRRHO, Specimen 46, Vat 7
> > Activity Recorded M.Y. 2302.22467
> > TERMINATION OF SPECIMEN ADVISED
> >
> >
> >
> > ------------------------------------
> >
> >

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