khatus
Member level 3
Hello guys i want to generate an interrupt after every 2.5 seconds.And toggle a led connected at GP0 pin of PIC PIC12F675 microcontroller. I am using 8 MHz crystal
Here is my code
But the led did not blink I can not configure the problem. Can any bode solve it for me??
Here is my code
Code:
/*******************************************************************************
Program for, generate an interrupt after every 2.5 seconds.And toggle a led connected at GP0 pin of PIC PIC12F675 using PIC12F675
Program Written by_ khatus
MCU:PIC12F675; X-Tal: 8MHz(internal). Compiler: mikroC pro for PIC v7.6.0
Date: 10-6-2021;
*******************************************************************************/
unsigned int cnt; // cnt varialbe declaration(global variable)
void timer_initialization() //function for timer initialization
{
OPTION_REG =0b00000111;
TMR0 = 61;//Timer0 preload value
INTCON.GIE=1; //Enables all unmasked interrupts
INTCON.T0IE=1; //Enables the TMR0 interrupt
}
void Interrupt()
{
if(TMR0IF_bit)// if TMR0IF bit is set
{
cnt++; //increment the counter
TMR0IF_bit=0;// if TMR0IF bit is cleared
TMR0 = 61; //preload timer0 with value
}
}
void main()
{
TRISIO.TRISIO0=0; //set I/O
GPIO.F0 = 0x00; //Initialyy all GPIO pin is HIGF
cnt = 0; // Initialize cnt
timer_initialization();
do {
if (cnt >= 100) // if count greater than or equal to 100
{
GPIO.F0 = ~GPIO.F0;// Toggle GPIOF0 LEDs
cnt = 0;// Reset cnt
}
} while(1);
}
But the led did not blink I can not configure the problem. Can any bode solve it for me??