Tuesday, 29 September 2015

Generate a 1s delay using TIMER1 in PIC16F877A

#include<pic.h>
void timer();
void main()
{
TRISD=0X00;
T1CON=0X39;
while(1)
{
PORTD=0XFF;
timer();
PORTD=0X00;
timer();
}
}
void timer()
{
int i;
TMR1L=0X00;
TMR1H=0X00;
for(i=0;i<2;i++)
{
while(TMR1IF==0);
TMR1IF=0;
}
}

No comments:

Post a Comment