Hi there,
I'm learning a lot just browsing this forum, but i'm quite stuck at the moment.
What i'm trying to do is the following :
I'm have to build a puls divider. When a jumper is on pin 4(gpio3), it counts a number of pulses on pin 5(gpio2), when the jumper is taken off it divides the number of pulses that were count by 10 and stores that in eeprom.
It then returns to it's normal routine, counting the pulses. If, say 500 pulses have been counted it must output one 50ms pulse every 50 pulses (500/10=50).
The problem is that im using pulsout plsout,5000 for the pulse output, but this delays the counting of the pulses with 50ms. Which results in me missing some of the incoming pulses.
Is there anything i can do to keep counting and give a command to make the pin high for 50ms ??
Code:'——-[ Device Initialization ]———————————————————————————————————— @ device pic12F635,intrc_osc_noclkout,wdt_off,pwrt_off,mclr_off,bod_off,cpd_off,protect_off '==== Variables ====================================== INCLUDE "modedefs.bas" DEFINE OSC 4 plsOUT var GPIO.0 plsIN var GPIO.2 LEARN var GPIO.3 ser var GPIO.1 i var word tel var word div var word output plsOUT output ser input plsIN input LEARN i=0 tel=0 div=0 pause 1000 main: if learn = 1 then goto reset read 1,i.lowbyte read 2,i.highbyte pauseus 50 div = i/10 pl1: if i = 0 then goto reset if plsin = 1 then tel = tel + 1 'Serout ser,T9600,[#tel,45,#i,45,#div,13,10] if tel >= div then pulsout plsout,5000 tel = 0 else goto pl0 endif pl0: if learn = 1 then goto reset if plsin = 1 then PAUSEUS 50 GOTO PL0 else goto pl1 endif else goto PL1 endif if learn = 1 then goto reset goto pl1 reset: i=0 tel=0 div=0 np: if learn = 1 then if plsin = 1 then i = i+1 goto wp else goto np endif wp: if learn = 1 then if plsin = 0 then goto np else goto wp endif else write 1,i goto setmem endif else goto setmem endif goto main setmem: if i = 0 then goto np write 1,i.lowbyte write 2,i.highbyte pauseus 50 setmem2: if learn = 0 then goto main else goto setmem2 endif theend: goto theend




Bookmarks