Problem Programming 16F870 when adding ON INTERRUPT


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2010
    Posts
    19

    Unhappy Problem Programming 16F870 when adding ON INTERRUPT

    I have a "strange" problem with a 16F870.

    I have a piece of code that gives me an error in the programmer application. But this error only happens if I introduce the line "ON INTERRUPT GOTO ISR". I remove that line and the PIC gets programmed correctly.

    Code:
    ...
    
    INTCON = %00100000 ' Enable TMR0 interrupts
    OPTION_REG = %00000111 ' Initialise the prescale
    TMR0 = 217 ' Load TMR0 register
    ON INTERRUPT GOTO ISR
    INTCON = %10100000 ' Enable Interrupts
    
    ...
    
    DISABLE
    ISR:
      TMR0 = 216
      
      ...	
      
      INTCON.2 = 0 ' Re-enable TMR0 interrupts
    RESUME ' Return to main program
    ENABLE
    
    END
    Any ideas?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Intcon.5 = 1 'enable tmr0
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Intcon.5 = 1 'enable tmr0
    Unfortunately this didn't do anything

    I just tested this code on a 16F870 and a 16F628A:

    Code:
    led     var     PORTB.7
    
    
            OPTION_REG = $7f        ' Enable PORTB pullups
    
            On Interrupt Goto myint ' Define interrupt handler
            INTCON = $90            ' Enable INTE interrupt
    
    loop:   High led                ' Turn LED on
            Goto loop               ' Do it forever
    
    
    ' Interrupt handler
            Disable                 ' No interrupts past this point
    myint:  Low led                 ' If we get here, turn LED off
            Pause   500             ' Wait .5 seconds
            INTCON.1 = 0            ' Clear interrupt flag
            Resume                  ' Return to main program
            Enable
    I get the error in the PROGRAMMER in both cases. The error is in the code verification stage.

    Why would the programmer give this type of error, as if the code was not being written properly to the PIC? If I remove the "ON INTERRUPT" line, the code saves perfectly. I have been using this programmer for a while and had no problems until this one.

    Is the PICBASIC compiler inserting code in a non-programable area or something?
    Last edited by dream-; - 2nd August 2010 at 21:49.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The error is in the code verification stage.
    What programmer are you using?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    What programmer are you using?
    VOLNIA USP 3.0

    I am in contact with the company and sent them the .hex, they will be investigating.

  6. #6
    Join Date
    Jul 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Problem Solved, it was an issue with the programmer. They updated my software (which updated the firmware too), and now it all works.

    Thank you Mackrackit for your responses!

  7. #7
    cmottaa's Avatar
    cmottaa Guest


    Did you find this post helpful? Yes | No

    Lightbulb Re: Problem Programming 16F870 when adding ON INTERRUPT

    Did u still got the update/firmware file...?
    Or something?
    The company dissappeared and my USP is dropping the same issue...

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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