TMR0 overflow problem


Results 1 to 11 of 11

Threaded View

  1. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Code:
    Runtimer:
    
    TMR0ON = 1
    TMR0IF = 0
    
    IF TMR0IF = 1 THEN HIGH PORTB.4
    
    GOTO Main
    Your polling technique has holes. When you enter Runtimer, you clear the flag and turn the timer on. If it has not overflowed, you go to main and spend a lot of time talking to your LCD ... then you turn the timer off. If the TMR0 overflows while in the LCD routine (odds are that this is where it will overflow), you clear the flag right before polling. Change to something like this:

    Code:
    Runtimer:
    
    TMR0ON = 1
    
    IF TMR0IF = 1 THEN 
    	HIGH PORTB.4
    	TMR0IF=0		' clear flag after you have trapped it
    ENDIF
    
    GOTO Main
    Last edited by paul borgmeier; - 17th June 2008 at 07:49. Reason: EDIT: also add comments - makes your code easier to read
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  4. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47
  5. 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

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