PDA

View Full Version : Timer problem



Tastature
- 31st July 2008, 17:26
I want to make timer. When time is 0 sec, timer give log 1 on some port.
I probe many mode, but nothing is good. I use 7 segment display.
This is shematic
http://www.elecfree.com/electronic/wp-content/uploads/2008/02/pic16f628-digital-clock-timer.gif
Can some body help me to do this.
I taste this : "If time=0 then porta.0 = 0" but not working

Code:


include "modedefs.bas"

trisb=0
cmcon=7
i var byte
j var byte
Number var word
Time var word
a var byte
b var byte
c var byte
d var byte

time = 40

goto Begin


Digit:
lookup i,[63,6,91,79,102,109,125,7,127,111],j
return
Begin:
number=time
d=number/1000
broj=broj-d*1000
c=number/100
broj=number-c*100
b=broj/10
a= number-b*10

i=a
gosub Digiti
low porta.4
portb=j
high porta.1
pause 1
i=b
gosub digit
low porta.1
portb=j
high porta.2
pause 1
i=c
gosub digit
low porta.2
portb=j
high porta.3
pause 1
i=d
gosub digit
low porta.3
portb=j
high porta.4
pause 1
if porta.5 = 0 then
time = time - 1
else
time = time + 10
endif

goto begin
end

skimask
- 31st July 2008, 17:40
Check your PIC's datasheet. What 'mode' are most pins/ports set to on a power up RESET?
Then try a 'blinky LED' program...then try to understand YOUR program.

Bruce
- 31st July 2008, 19:38
I taste this : "If time=0 then porta.0 = 0" but not working
Which PIC are you using?

Have you set TRISA.0=0 so PORTA.0 is an output?