Two words: Loop overhead. The behind-the-scenes calculations for the For loop take an increasing percentage of the overall loop time as X gets larger and/or Y gets smaller. If you looked at the case that seems to be fine (Y=2000 and above as you mention) with an oscilloscope or some sort of pulse-length measurement to check how long the LED is really on for, you'd see that it is in fact slightly off. Doing precision delays of adjustable length, where the details of how many cycles the loop overhead takes is vital, becomes a little tricky... J Mark Wotton wrote: > Hi, > > I'm having a strange problem with inconsistent timing using pauseus > (from picbasic). I wrote the following test program: > > define OSC 08 > osccon = %01110010 > > for i = 1 to 10 > high statusled > for j = 1 to X > pauseus Y > next j > low statusled > for j = 1 to X > pauseus Y > next j > next i > > for the following X,Y pairs > > 1000,5000 > 2500,2000 > 5000,1000 > 10000,500 > 25000,200 > > For Y=2000 and above, I get exactly what I expect: an LED flashing > once a second for 10 seconds. For lower parameters to pauseus, however > i get the following results: > > 1000,5000 -> 10s > 2500,2000 -> 10s > 5000,1000 -> 5s > 10000,500 -> 2.6s > 25000,200 -> 1.0s > > pauseus is meant to work down to 12 us for my 8mhz clock, according to > the PicBasic manual: can anyone suggest what might be wrong, or what > tests I might run to narrow it down? > > Mark > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist