Blinking of a port when a switch is pressed (switch is connected to the external interrupt pin)
#include<pic.h>
void delay(int);
void main()
{
int i;
TRISB=0XFF;
TRISC=0X00;
GIE=1;
PEIE=1;
INTE=1;
while(1)
{
PORTC=0X80;
for(i=0;i<8;i++)
{
PORTC=PORTC>>1;
}
}
}
void interrupt isr()
{
if(INTF==1)
{
PORTC=0XFF;
delay(25);
PORTC=0X00;
delay(25);
}
INTF=0;
}
void delay(int k)
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<1000;j++);
}
#include<pic.h>
void delay(int);
void main()
{
int i;
TRISB=0XFF;
TRISC=0X00;
GIE=1;
PEIE=1;
INTE=1;
while(1)
{
PORTC=0X80;
for(i=0;i<8;i++)
{
PORTC=PORTC>>1;
}
}
}
void interrupt isr()
{
if(INTF==1)
{
PORTC=0XFF;
delay(25);
PORTC=0X00;
delay(25);
}
INTF=0;
}
void delay(int k)
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<1000;j++);
}
No comments:
Post a Comment