EmbeddedRelated.com
Forums

TimerB - Watchdog issues on OP7200

Started by scottmack1 February 16, 2006
I have a project to produce a variable pulse on selectable outputs of 
an OP7200.  The customers range is from about a millisec to a sec.  
Every few seconds I need to be able to display and change the running 
time and number of cycles created while the system is running.  I 
started using 'costate' logic with 'waitfor' lines and
included 
multiple 'yield' statements after the 'glprintf' statements
to get me 
back to the state where the logic set or cleared the selected 
outputs.  The program worked fine except for a ~200ms hit each time I 
ran the state that updated the screen, even with the 'yield' 
statements as indicated.  This was not totally unexpected, but worth 
the try.

I now have a program utilizing the SHDesign TimerB lib.  Although I'm 
sure this is a much better design, I have either a 'communication 
error' to DC or a System Reset that occurs when run stand-alone which 
I am sure must be a result of the watchdog check.  I tried 
the 'Disable_HW_WDT()' and lost the 'waitfor' clock used for
the rest 
of my state machine.  It seems what I need to do is 'hitwd' myself in 
a 1 sec 'waitfor' state, however, I am not sure how this can work any 
better if the system watchdog can not even grab control long enough 
to satisfy itself.  I am questioning if my C ISR is too long, listed 
below, but the Reset occurs even when the timing is set for 100ms ON 
and 100ms OFF time.

Can anybody help with the basic timing/watchdog concept or where 
things may be going wrong?  What is a proper interrupt level (lower 
than the watchdog)?  Can one disable the watchdog and not the 
interval clocks?

nodebug root void TimerBRoutine()   // Output State Check
{
   if ( intOut_State )
   {
      //Set any of outputs selected 'OFF'
      digOut( 0, 0 );   // Set any of outputs
      digOut( 1, 0 );   //   that may be 'ON'
      digOut( 2, 0 );   //     to 'OFF' state
      TimerBUninit();   // Need to stop the timer interrupts
      TimerBInit( longValve_off_time*1000, 2 ); // OFF msec timer
      longTotal_cycles = longTotal_cycles + 1;
      intOut_State = 0;
   }else{
      //Set any of outputs selected 'ON'
      digOut( 0, (intOutput_byte & 0x01) ); // Set outputs per mask
      digOut( 1, ((intOutput_byte >> 1) & 0x01) ); // Shift mask
      digOut( 2, ((intOutput_byte >> 2) & 0x01) ); // Shift mask
      TimerBUninit();                          // Stop timer intr's
      TimerBInit( longValve_on_time*1000, 2 ); // ON msec timer
      intOut_State = 1;
   }
}
Thanks for the help, 
Scott
	
It looks like I may have solved the problem by simply setting the 
interrupt level to 1 rather than 2.  I have not rechecked the outputs 
with a scope yet, but the OP7200 does not seem to trip on a watchdog 
like it did before.

What happens on what interrupt priority?  Where does one find this 
info?  Am I goofing up the interval time clocks or something else by 
setting the interrupt level at 1?  I bought the User Manual and the 
Function Reference manual and since I have not seen an explaination 
of this, I missed it or there must be something more.  Is it 
downloadable?

Couple more questions:
  How does one pass a value back and forth from C to assembler if I 
were to rewrite the ISR in assembler?  Does ZWorld have a manual that 
walks you through this?  (My assember days are with the 8085 chip, to 
which half of you will likely say "the what?", but I might like to be 
able to give it a try.)
  I see a version 9.40 on the web site.  Is my DC purchased with the 
development kit freely upgradeable to that via download?  What is the 
policy for how long one can upgrade?  I have seen some issues that 
people seem to be having problems with; will one be able to upgrade 
to the next version after 9.40?
  If I end up with another Zworld job, it might be good to get a book 
that would cover all aspects from hardware to bios software and 
programming for some of these Rabbit Core Modules.  I would probably 
stick with the RCM rather than doing my own board at the chip level.  
Does anyone have a general reference recommendation?

Thanks,
Regards,
Scott

--- In rabbit-semi@rabb..., "scottmack1" <scottmack1@...> 
wrote:
>
> I have a project to produce a variable pulse on selectable outputs 
of 
> an OP7200.  The customers range is from about a
millisec to a sec.  
> Every few seconds I need to be able to display and change the 
running 
> time and number of cycles created while the system
is running.  I 
> started using 'costate' logic with 'waitfor' lines and
included 
> multiple 'yield' statements after the 'glprintf'
statements to get 
me 
> back to the state where the logic set or cleared
the selected 
> outputs.  The program worked fine except for a ~200ms hit each time 
I 
> ran the state that updated the screen, even with
the 'yield' 
> statements as indicated.  This was not totally unexpected, but 
worth 
> the try.
> 
> I now have a program utilizing the SHDesign TimerB lib.  Although 
I'm 
> sure this is a much better design, I have either a
'communication 
> error' to DC or a System Reset that occurs when run stand-alone 
which 
> I am sure must be a result of the watchdog check. 
I tried 
> the 'Disable_HW_WDT()' and lost the 'waitfor' clock
used for the 
rest 
> of my state machine.  It seems what I need to do
is 'hitwd' myself 
in 
> a 1 sec 'waitfor' state, however, I am
not sure how this can work 
any 
> better if the system watchdog can not even grab
control long enough 
> to satisfy itself.  I am questioning if my C ISR is too long, 
listed 
> below, but the Reset occurs even when the timing
is set for 100ms 
ON 
> and 100ms OFF time.
> 
> Can anybody help with the basic timing/watchdog concept or where 
> things may be going wrong?  What is a proper interrupt level (lower 
> than the watchdog)?  Can one disable the watchdog and not the 
> interval clocks?
> 
> nodebug root void TimerBRoutine()   // Output State Check
> {
>    if ( intOut_State )
>    {
>       //Set any of outputs selected 'OFF'
>       digOut( 0, 0 );   // Set any of outputs
>       digOut( 1, 0 );   //   that may be 'ON'
>       digOut( 2, 0 );   //     to 'OFF' state
>       TimerBUninit();   // Need to stop the timer interrupts
>       TimerBInit( longValve_off_time*1000, 2 ); // OFF msec timer
>       longTotal_cycles = longTotal_cycles + 1;
>       intOut_State = 0;
>    }else{
>       //Set any of outputs selected 'ON'
>       digOut( 0, (intOutput_byte & 0x01) ); // Set outputs per mask
>       digOut( 1, ((intOutput_byte >> 1) & 0x01) ); // Shift mask
>       digOut( 2, ((intOutput_byte >> 2) & 0x01) ); // Shift mask
>       TimerBUninit();                          // Stop timer intr's
>       TimerBInit( longValve_on_time*1000, 2 ); // ON msec timer
>       intOut_State = 1;
>    }
> }
> Thanks for the help, 
> Scott
>
	
If you bought any version 9.xx of DC you can freely upgrade to any new v9.xx. When they change the major version number, in this case going to v10.xx, then you have to pay an upgrade fee.

There is a small section in the DC User's Manual about assmebly programming. Its not much, but it does tell you that the first argument of an assembly procedure is passed via register HL, for integers and bytes, and returns are also made via HL, again for integers. There is a book out about Rabbit programming that may contain more details on this. I don't remember the name, but if you search the archives or search on Amazon.com you should be able o fine it.

As for interrupt priorities, its a great mystery as to where you find that info. I'm sure someone more knowledgeable will chime in before too long.----- Original Message ----
From: scottmack1 <s...@frontiernet.net>
To: r...@yahoogroups.com
Sent: Friday, February 17, 2006 5:01:03 AM
Subject: [rabbit-semi] Re: TimerB - Watchdog issues on OP7200

It looks like I may have solved the problem by simply setting the
interrupt level to 1 rather than 2.  I have not rechecked the outputs
with a scope yet, but the OP7200 does not seem to trip on a watchdog
like it did before.

What happens on what interrupt priority?  Where does one find this
info?  Am I goofing up the interval time clocks or something else by
setting the interrupt level at 1?  I bought the User Manual and the
Function Reference manual and since I have not seen an explaination
of this, I missed it or there must be something more.  Is it
downloadable?

Couple more questions:
  How does one pass a value back and forth from C to assembler if I
were to rewrite the ISR in assembler?  Does ZWorld have a manual that
walks you through this?  (My assember days are with the 8085 chip, to
which half of you will likely say "the what?", but I might like to be
able to give it a try.)
  I see a version 9.40 on the web site.  Is my DC purchased with the
development kit freely upgradeable to that via download?  What is the
policy for how long one can upgrade?  I have seen some issues that
people seem to be having problems with; will one be able to upgrade
to the next version after 9.40?
  If I end up with another Zworld job, it might be good to get a book
that would cover all aspects from hardware to bios software and
programming for some of these Rabbit Core Modules.  I would probably
stick with the RCM rather than doing my own board at the chip level. 
Does anyone have a general reference recommendation?

Thanks,
Regards,
Scott