Tuesday, 20 October 2015

TIMER INTERRUPT PROGRAMMING OF PIC16F877A

Blink a port in every 1sec

#include<pic.h>
void delay(int);
int m=0;
void main()
{
TRISC=0X00;
OPTION=0X07;
TMR0=0X00;
GIE=1;
PEIE=1;
TMR0IE=1;
while(1);
}
void interrupt isr()
{
if(TMR0IF==1)
{
m++;
while(m<30)
{
PORTC=0XFF;
delay(10);
PORTC=0X00;
delay(10);
}
}
delay(100);
TMR0IF=0;
}
void delay(int k)
{
int j,i;
for(i=0;i<k;i++)
for(j=0;j<1000;j++);
}

No comments:

Post a Comment