Time interrupt problem


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2005
    Posts
    70

    Default Time interrupt problem

    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.
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post tmr0 and tmr1

    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

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post Help.Please advice

    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

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Nov 2006
    Posts
    33


    Did you find this post helpful? Yes | No

    Post

    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.

Similar Threads

  1. INT interrupt problem
    By netstranger.nz in forum General
    Replies: 5
    Last Post: - 13th October 2009, 07:52
  2. Instant interrupt problem (very strange)
    By yusoweird in forum General
    Replies: 2
    Last Post: - 31st October 2006, 16:15
  3. Time Interrupt problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th February 2006, 23:49
  4. Interrupt?? problem
    By scorpion in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th July 2005, 04:14
  5. Interrupt and Time Out
    By Tissy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th March 2005, 01:10

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts