hi, I am using a PIC16f690. i trying to make a LED on RC0 flash with the help of timers. The problem is that the LED is constantly on. using MPLAB X IDE v2.20 and xc8.
#include<PIC16f690.h>
#pragma config FOSC = INTRCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // MCLR Pin Function Select bit (MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = ON // Internal External Switchover bit (Internal External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
int main(void)
{
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
T1CONbits.T1CKPS0 = 1;
T1CONbits.T1CKPS1 = 1;
PIE1bits.TMR1IE = 1;
T1CONbits.TMR1ON = 1;
TRISC = 0;
PORTC = 0;
while(1);
}
void interrupt IRS(void)
{
if(PIR1bits.TMR1IF == 1)
{
PORTCbits.RC0 ^= 1;
PIR1bits.TMR1IF = 0;
}
}