Well, I've tried that too... same thing..
Sometimes it works on the second try... i do not know.. 
Well, got another problem, could you help again???
I'm trying to make TMR1 interrupt at 36kHz.
It uses a 20Mhz crystal... The code is below:
Code:
@ DEVICE pic16F877, HS_OSC ; System Clock Options
@ DEVICE pic16F877, WDT_OFF ; Watchdog Timer
@ DEVICE pic16F877, PWRT_ON ; Power-On Timer
@ DEVICE pic16F877, BOD_OFF ; Brown-Out Detect
@ DEVICE pic16F877, CPD_OFF ; Data Memory Code Protect
@ DEVICE pic16F877, PROTECT_OFF
define OSC 20
INT VAR PIR1.0 ' OVERFLOW flag
START VAR T1CON.0 ' START TMR1
LOAD VAR word
'------- Configurações iniciais --------------------
TRISA = %00000000 ' PORTA
TRISB = %00000000 ' PORTB
TRISC = %00000000 ' PORTC
TRISD = %00000000 ' PORTD
TRISE = %00000000 ' PORTE
INTCON = %11000000 ' enable global interrupt
OPTION_REG = %00000000
ADCON1 = %10001111 ' all digital
T1CON = %00000000 ' TMR1 1:1 prescaler
PIE1 = %00000001 ' Henable TMR1 INT
START = 0
INT = 0
LOAD = 65404 ' INT. 36KHz
'---------------------------------------------------
ON INTERRUPT GOTO SINUS
TMR1L = LOAD.lowbyte
TMR1H = LOAD.highbyte
START = 1
PORTB.0 = 1
MAIN:
GOTO MAIN
DISABLE
SINUS: INT = 0
TMR1L = LOAD.lowbyte
TMR1H = LOAD.highbyte
PORTB.0 = 1 ' JUST TO MEASURE THE FREQ. ON OSCILLOSCOPE
PORTB.0 = 0
RESUME
ENABLE
end
The oscilloscope do not shows 35.9kHz, but 30~33kHz...
Anything I can do?
Thanks again!
Bookmarks