Interrupt problem.


Closed Thread
Results 1 to 3 of 3

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi Peter,

    Looks like you're reloading timer1 before it can over-flow (not sure without knowing the osc speed), but try something like this.
    Code:
    PRESET  VAR WORD
    ELAPSED VAR BYTE
    PRESET = 12000 
    
        T1CON=%00110000  ' Set timer1 prescaler as 1:8
        PIR1.0=0	       ' Clear timer1 overflow flag		
        PIE1=%00000001      ' Enable interrupt on timer1 overflow	
        TMR1H=PRESET.highbyte  ' Load timer1 high byte
        TMR1L=PRESET.Lowbyte  ' Load timer1 low byte
        T1CON.0=1               ' Turm on timer1
        INTCON=%11000000   ' Global & peripheral interrupts enabled
      	
        ON INTERRUPT goto TICKER
        
    MAINLOOP:
        TOGGLE PORTB.5
        ELAPSED = ELAPSED + 1
        GOTO MAINLOOP
        
        DISABLE
    TICKER:
        TOGGLE PORTB.0          ' Toggle PORTB.0
        TMR1H = PRESET.highbyte ' Load timer1 high byte
        TMR1L = PRESET.Lowbyte  ' Load timer1 low byte
        PIR1.0=0                ' Clear TMR1 overflow flag
        RESUME
        ENABLE
    
        END
    HTH....;o}
    Last edited by Bruce; - 12th August 2005 at 18:26.
    Regards,

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

  2. #2
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Thumbs up

    Yeah, Thanks Bruce, that done it.
    Isn't it amazing, once again my problem was so simple that I couldn't see it for trying. Makes me feel like a bloody idiot, (as is usual with my little errors) when that happens. The theory was right, just the placement wrong. Anyway, thanks a lot Bruce for your assistance.
    Regards,
    Peter Moritz.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 20:52
  2. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 02:34
  3. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 21:58
  4. Interrupt stack overflow problem with Resume {label}
    By Yuantu Huang in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd May 2005, 02:17
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

Members who have read this thread : 0

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