PDA

View Full Version : pauseus behaviour, 18f2455



mark_wotton
- 7th September 2006, 09:33
Hi,

I'm having a strange problem with inconsistent timing using pauseus. 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

and tested it, substituting 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

mister_e
- 7th September 2006, 14:15
i'm not sure but what about
DEFINE OSC 8

Define's must be written perfectly OR they will never be considered... but it's a guess.

For few uSec, i usually use assembler. @4MHz each @ nop is 1 uSec, and, of course, each @ nop @ 8MHz is 0.5 uSec.

mark_wotton
- 7th September 2006, 14:22
Thanks, I'll remember that. But the root cause of the problem was forgetting that you can't fit "10000" into a byte. Oops...

mister_e
- 7th September 2006, 14:28
LMAO! ok...

sayzer
- 7th September 2006, 15:39
Thanks, I'll remember that. But the root cause of the problem was forgetting that you can't fit "10000" into a byte. Oops...


If you have to use Byte variables, you can actually use small numbers and with PauseUS command you may do the following.

PausUS Y*100

say Y= 50 then PauseUS Y*50 will give you PauseUs 5000.

and others the same way...


---------------