alokdaga
Member level 2
- Joined
- Feb 10, 2011
- Messages
- 44
- Helped
- 9
- Reputation
- 18
- Reaction score
- 9
- Trophy points
- 1,288
- Activity points
- 1,479
I have enabled tmr0 in 16f72. I am using the following code:
If I do not use the pause command in main loop - LED toggles rightly else it does not... Can anybody guide suitable...
Code:
DEFINE OSC 4
i var byte
ADCON1=7
Include "modedefs.bas"
op var porta.0
led var porta.1
'
Date var byte
Month var byte
Year var byte
Hour var byte
Minute var byte
Second var byte
TICKS VAR BYTE
' Set TMR0 to interrupt every 16.384 milliseconds
OPTION_REG = $55 ' Set TMR0 configuration and enable PORTB pullups
INTCON = $a0 ' Enable TMR0 interrupts
On Interrupt Goto tickint
LOW LED
Main:
Toggle OP
pause 4000
GOTO MAIN
tickint:
DISABLE
ticks = ticks + 1 ' Count pieces of seconds
If ticks < 61 Then tiexit ' 61 ticks per second (16.384ms per tick)
' One second elasped - update time
ticks = 0
second = second + 1
TOGGLE LED
If second >= 60 Then
second = 0
minute = minute + 1
If minute >= 60 Then
minute = 0
hour = hour + 1
Endif
Endif
tiexit:
INTCON.2 = 0 ' Reset timer interrupt flag
INTCON.1=0
Resume
End
If I do not use the pause command in main loop - LED toggles rightly else it does not... Can anybody guide suitable...