PDA

View Full Version : Execution time in programme



Adrian
- 16th November 2007, 20:57
At the risk of looking stupid, please put me out of my misery and tell me what I'm not understanding. The following snippet of code is from a lap counter feeding a 7 segment display driver.

start_loop:
if stpin = 1 then
goto start_loop
endif

main_loop:
IF tkpin = 1 THEN GOTO main_loop
pause 25
cntr = cntr + 1
PULSOUT CLK, 500
if cntr = laps then
PULSOUT TIMER_EN, 5000
END
ELSE
goto wait_TKloop
endif

Laps are set earlier in the programme, say 10. When the 10th lap is signalled via TKPIN going low then the signal is debounced, counter incremented by one, a clock pulse sent forward to the next circuit and on the 10th lap the LAPS and CNTR are equal so a final stop signal is flagged and the programme ends. I have scoped the time delay between receiving the TKPIN pulse and the falling edge Pulsout at TIMER_EN. It is always TWICE the debounce time PAUSE plus a couple of mSecs. In the example shown it is 53mS. Why twice? I expected to see about 27mS. Why is this looping twice. I guess this is stupidly easy but I've gone dumb.
Adrian

Adrian
- 16th November 2007, 22:29
Got it! I had a DEFINE OSC 8 line in the programme with a 4Mhz resonator! Duh!! Only taken me about 4 hours to find.....!!

Adrian