PDA

View Full Version : Time interrupt problem



chai98a
- 22nd November 2006, 14:04
I got problem with time interrupt not work ....

How have known rule of time interrupt function pls advise, due to we found probble after we add more code on interrut sub and program will not work after run, But can done complier with out error.

here sample working :Portb.5 will flash after run.

OPTION_REG = $57 '57 Set TMR0 configuration
INTCON = $A0 ' Enable TMR0 interrupts

ON INTERRUPT GOTO INT

Main:
TMR0 = 0
Gosub check_Lstatus
Strobe = 1'strobe off
latch = 1'lactch off
clock = 1'CLOCK OFF ACTIVE HIGH
Sin3 = 0
Sin2 = 0
SIN1 = 0
goto loop
...
....
...
disable
INT:
INTCON.2 = 0
TMR0 = 0
'HSEROUT ["n1 ",dec n,13,10]
TOGGLE PORTB.5

resume
enable

But not work if we add some more code below to replace or below " toggle portb.5"

=======

disable
INT:
INTCON.2 = 0
TMR0 = 0
'HSEROUT ["n1 ",dec n,13,10]
TOGGLE PORTB.5
FOR K = 0 TO 2
READ (FONT1+K),COLUM2
READ (FONT2+K),COLUM0
READ (SCANROW0+K),ROW0

GOSUB SCANDATASIN8BITLOWBYTE

READ (FONT0+K),COLUM3
READ (FONT1+K),COLUM1
READ (SCANROW1+K),ROW1

GOSUB SCANDATASIN8BITHIGHBYTE

LATCH = 0
LATCH = 1
STROBE = 0
STROBE = 1

next k

FOR K = 8 TO 10
READ (FONT1+K),COLUM2
READ (FONT2+K),COLUM0
READ (SCANROW0+K),ROW0

GOSUB SCANDATASIN8BITLOWBYTE

READ (FONT0+K),COLUM3
READ (FONT1+K),COLUM1
READ (SCANROW1+K),ROW1

GOSUB SCANDATASIN8BITHIGHBYTE

LATCH = 0
LATCH = 1
STROBE = 0
STROBE = 1

NEXT K
resume
enable
============


Who have pls advise too .. thank you

Pls see full code on attached file.

Bruce
- 22nd November 2006, 15:23
It doesn't work because you are using GOSUBs inside your interrupt handler,
and jumping into routines outside the disable/enable block.

PBP is inserting interrupt checking code in the sub-routines you enter with
these GOSUBs. Once you jump outside the disable/enable block, you land on
code testing for the interrupt condition, and program execution returns to
the entry point of your interrupt handler.

DragonBall_6
- 5th December 2006, 10:06
Hi all

Can we use 2 interrupt at the same time?

(i)TMR1 act as sending pulse 4.32 second to the driver.
(ii)TMR0 act as 1 second elapsed to create time and date.

Please advice
Thanks

mister_e
- 5th December 2006, 15:44
Yes you can do it, you can use ALL PIC interrupts at the time. In the ISR you need to track it down. Bear in mind to keep your ISR as short as possible.

DragonBall_6
- 6th December 2006, 00:52
Hi

Thank to the advice.

*************ISR you need to track it down????******************

Below are the basic program:-
Is that what you mean????

' Initialization of TMR0 and TMR1
'
ON INTERRUPT clockpulse
ON INTERRUPT elapsed time

main:
'
'some coding here
'
'
goto main

DISABLE

clockpulse:
'some coding here
'
'
'
'
'
RESUME
DISABLE
elapsed time:
IF tick<16 then
tick = 0
bs = bs + 1
'some coding here
'
'
' reset tmr0 flag
RESUME

END

Please advice thank

HenrikOlsson
- 6th December 2006, 06:25
DragonBall,
You have now asked the same question in atleast three different threads and you are not reading the responses you are getting.

You can not use two ON INTERRUPT statements. You have to, in one SINGLE ISR, determine what caused the interrupt by looking at the different interrupt flags, located in INTCON, PIR1 and PIR2 (For16F87x). If you have TMR0 and TMR1 running and interrupts enabled for both, when the interrupt fires you look at the T0IF and TMR1IF flags to determine which one caused the interrupt.

I think you are making this more comlicated than it needs to be, IMO you only need one timer interrupt. Look for a suggestion in one of the other threads where you asked this question.

/Henrik Olsson.

DragonBall_6
- 6th December 2006, 15:15
Hi Henrik Olsson.

I actually had read all the threads that ppl send to me. I just want to heard ppl's suggestion. If I know that the multiple interrupt will make me complicated then I will heard to your advice.

I really appreciated all the ppl's reply.
one thing is i have success doing the LCD diplays.

Thank to your reply again.

Please advice me and guide me if i have problem thanks.