PDA

View Full Version : Problem Programming 16F870 when adding ON INTERRUPT



dream-
- 2nd August 2010, 20:21
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.


...

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?

mackrackit
- 2nd August 2010, 21:29
Intcon.5 = 1 'enable tmr0

dream-
- 2nd August 2010, 21:47
Intcon.5 = 1 'enable tmr0

Unfortunately this didn't do anything :(

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


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?

mackrackit
- 2nd August 2010, 23:20
The error is in the code verification stage.
What programmer are you using?

dream-
- 2nd August 2010, 23:44
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.

dream-
- 3rd August 2010, 00:49
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!

cmottaa
- 10th March 2011, 07:56
Did u still got the update/firmware file...?
Or something?
The company dissappeared and my USP is dropping the same issue...