Quote Originally Posted by Charles Linquis View Post
You should confirm that the device is really running at 4Mhz. Perhaps it is running at 2. You often have to set up the OSCCON register. Check the datasheet.
Also, the interrupt is triggered right away beause you have not cleared the interrupt flag BEFORE enabling the interrupt (usually PIR.x, but again, check your device).
Hi Charles;

First of all, thanks for your answer.

If you look at my code, you can see that the OSCCON is configured correctly. I allready found the time issue. The pic was actually running at 4Mhz, however the main code was executed 2 times. To resolve this problem, i change this code:

Code:
Main:
  @ SLEEP
  INTCON.0 = 0
  High led
  Pause 5000
  low led 
  GOTO Main
With this, just changed one line;

Code:
Main:
  @ SLEEP
  High led
  Pause 5000
  low led 
  INTCON.0 = 0
GOTO Main
Now the main code is only executed one time and them goes to sleep.

However, on power up the led still turns on, but it shoul not, because the first instruction is sleep. I follow your advice of clearing the interrupt flag before, however the behavior is the same.
I'm still try to figure it out. If someone has any idea please let me know.

Thanks