piclist 2001\04\04\180139a >
Thread: 16C73 vs 16F873: stability and timing
www.piclist.com/techref/microchip/devices.htm?key=16F
flavicon
face BY : Mike Mansheim email (remove spam text)



Here's a general observation, but unfortunately it doesn't have anything
to do with differences between the C and F parts.

       // sync with transition of timer 1
       timer = T1_HIGH;        // changes at 128 Hz
       while (timer = T1_HIGH);

will loop until T1_HIGH equals 0, so the intent is to wait here until the
timer rolls over.  I am quite leery of trying to catch a timer at an
exact value while polling.  This while statement will compile into
several instructions - I would be concerned that the timer will roll and
go beyond zero while you're working on the compare, and you'll miss it.
Timer 1 is a 16 bit timer, so it will increment 65,536 times.  At 128 Hz,
that's approx. .12 us per timer tick.  If you are running a 10M clock,
each instruction takes .4 us.
This doesn't explain why a C would work and an F would not, unless
something else changed.  Did you:
 - change the timer frequency?
 - change the clock?
 - change the timer you are using?
   (the other two are 8 bit timers, which will increment only 256 times)

This doesn't relate directly to your question, but I'm curious about
this chunk:

       timer = T1_HIGH;        // update current state
       // count transitions of INBIT
       while (poll_count) {
               if (clk_bit != INBIT) {
                       clk_bit = INBIT;
                       result++;
               }
               if (timer != T1_HIGH) {
                       timer = T1_HIGH;
                       poll_count--;
               }
       }

With the disclaimer that it's been a long day, it's not immediately
obvious to me what the timer comparison does here.  I would think that
(timer != T1_HIGH) would always be true, and poll_count would simply
be decremented every time through the loop.  What am I missing??

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


<OF10BAF237.B081D149-ON86256A24.0074B650@graco.com>

See also: www.piclist.com/techref/microchip/devices.htm?key=16F
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) 16C73 vs 16F873: stability and timing

month overview.

new search...