tmr2 interrupt problem


Results 1 to 28 of 28

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    i see you use some GOSUBs & Return in your ISR... not a good idea to me...

    Observe the way your program will flow, assuming there's no problem with the use of Gosub and Return (erm), your program will execute all lines.. and finally jump to...
    Code:
            counter = %11111111 'to take care that no segment is blinking harder
            todec = %00000000'todec >> 4 
            gosub segmentsshiftout
            
    segmentsshiftout:
            SHIFTOUT PORTB.0, PORTB.1, LSBFIRST,[counter\8,segments\8]   'data, clock
            pulsout PORTA.4,1        
            return        
    it's kinda dangerous here... once it have execute once the segmentsshiftout sub, it will execute it once again and meet a RETURN without a GOSUB... where the program branch now??? i guess at the begining of your ISR... or.. mmm... resume to your main loop, but as you NEVER EVER clear the interrupt flag, it will automatically jump back to your ISR.

    try to add a GOTO after your last GOSUB segmentsshiftout, which will send it at the end of your ISR...
    Code:
            counter = %11111111 'to take care that no segment is blinking harder
            todec = %00000000'todec >> 4 
            gosub segmentsshiftout
    
    	GOTO RESUME_ISR	' <-- Add this
    	
    segmentsshiftout:
            SHIFTOUT PORTB.0, PORTB.1, LSBFIRST,[counter\8,segments\8]   'data, clock
            pulsout PORTA.4,1        
            return        
    	'
    	'
    	'
    	'
    	'
    RESUME_ISR: ' <-- And this
            TMR2 = RELOAD
            TMR2ON = 1        
            TMR2if=0  ' Clear interrupt flag
    
            resume
            enable
    Last edited by mister_e; - 29th December 2007 at 00:48.
    Steve

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

Similar Threads

  1. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  2. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  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