Google

Jul 18, 2008

Edge triggeringin PIC16F877A

i am using the following program for edge triggering. i am using PIC16f877a Controller.

i put one key for the external interrupt.And using RB0/INT pin for the edge triggering concept.and i connected one led on porta to see the output.

i am using the HITECH c compiler

#include<pic.h>

#include<stdio.h>



#define ldata PORTD

#define RS RC4

#define RW RC5

#define EN RC6



unsigned int d;



void Init_Int(void);

void cmd(unsigned char);

void cardiac_lcd(unsigned int);

void Msdelay(unsigned int);

void convert_disp(unsigned char);





void Msdelay(unsigned int time)

{

unsigned int i,j;

for(i=0;i<time;i++)

for(j=0;j<1275;j++);

}



void Lcd_disp()

{

cmd(0x38);

Msdelay(5);

cmd(0x0e);

Msdelay(5);

cmd(0x01);

Msdelay(5);

cmd(0x80);

Msdelay(5);

}

void cardiac_lcd(unsigned int value1)

{

ldata=value1;

RS=1;

RW=0;

EN=1;

Msdelay(1);

EN=0;

}



void cmd(unsigned char value)

{

ldata=value;

RS=0;

RW=0;

EN=1;

Msdelay(1);

EN=0;

// return;

}



void convert_disp(unsigned char val)

{

unsigned int b,c;

b=val/10;

c=val%10;

d=b|0x30;

}



void Init_Int()

{

RP0=1;

INTEDG=1;

// RPBU=1;

RP0=0;

GIE=1;

INTE=1;

}

void interrupt intr_tc()

{

unsigned int a=0;

if(INTF==1)

a=a++;

// if(a>10)

{

// convert_disp(a);

RA1=1;

}

INTF=0;

}

void main()

{

PORTA=0x00;

TRISA=0x00;

PORTB=0x00;

TRISB=0xff;

PORTC=0x00;

TRISC=0x00;

PORTD=0x00;

TRISD=0x00;

Lcd_disp();

Init_Int();

cardiac_lcd(d);

while(1)

{

//cardiac_lcd(d);

//RA1=0;

}

}




if cant able to bring the no of counts in LCD display.and led is blinking then do the following
for the lcd line initialization (0x38) takes more time , so that it would be better to pass 0x38 three times. i had only checked that much and also increase the delay time

You might be also interested in:

:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI
:: Interfacing Stepper Motor to 8086 using 8255

No comments: