Interrupt problem.


Results 1 to 3 of 3

Threaded View

  1. #2
    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 17:26.
    Regards,

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

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  3. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20: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, 01:17
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01: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