Total Pageviews

Tuesday, January 28, 2014

EXTERNALINTERRUPT(PIC16F877A)-programming





PROGRAM

#include<pic.h>
#include<htc.h>

#define RS RC0
#define RW RC1
#define EN RC2
#define D0 RD0
#define D1 RD1
#define D2 RD2
#define D3 RD3
#define D4 RD4
#define D5 RD5
#define D6 RD6
#define D7 RD7 

#define _XTAL_FREQ 4000000
__CONFIG(WDTDIS & XT & UNPROTECT);
#include"lcd.h"
char a[10];
int count=0,i;
void interrupt isr()
{
if(INTF==1)
{
count++;
i=count;
a[1]=i%10+0x30;
i=i/10;
a[2]=i%10+0x30;
if(count<10)
{
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_Char(a[1]);
}

if(count>9)
{
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_Char(a[2]);
Lcd8_Set_Cursor(1,1);
Lcd8_Write_Char(a[1]);
}
INTF=0;
}
}



void main()
{

TXSTA=0X24;
RCSTA=0X90;
SPBRG=0X19;
TRISC=0x80;
TRISD=0x00;
TRISB=0x01;
TXIF=0;
RCIF=0;
GIE=1;
PEIE=1;
RCIE=1;
INTE=1;
INTEDG=1;
INTF=0;
Lcd8_Init();
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_String("interrupt");
while(1);
}

No comments:

Post a Comment