Code:
#include <18f4331.h>
#include <def_4331.h>
#FUSES HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOPUT,NOCPD,NODEBUG,NOFCMEN,NOCPB,STVREN,NOPWMPIN,HPOL_LOW
//#FUSES MCLR,NOIESO,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOWRT,NOEBTRB,T1STANDARD,NOWINEN
//#fuses EXCLKc3
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(c)
#use fast_io(a)
#use fast_io(d)
#use fast_io(e)
INT16 XUNG,XUNG1,XUNG2;
#INT_EXT //RC3
VOID DEM_NGAT()
{
//disable_interrupts(int_ext);
XUNG++;
//if ((XUNG >= en_t)&&(flag_ngat == 0))
// {
// ngat = 1;
// flag_ngat = 1;
// XUNG = 0;
// }
// enable_interrupts(int_ext) ;
}
#INT_EXT1 //RC4
VOID DEM_NGAT_1()
{
XUNG1++;
// INT1IF=0;
}
#INT_EXT2 //RC5
VOID DEM_NGAT_2()
{
XUNG2++;
// INT2IF=1;
}
void main()
{
/////////////////////////////
trisa0=0;
trisa5=0;
trisb0=0;
ra0=ra5=rb0=1;
////////////////////////////
trisc4=1;
trisc3=1;
trisc5=1;
xung=xung1=xung2=0;
enable_interrupts(INT_EXT);
enable_interrupts(INT_EXT1);
enable_interrupts(INT_EXT2);
ext_int_edge(0, L_TO_H );
ext_int_edge(1, L_TO_H );
ext_int_edge(2, L_TO_H );
rc3=rc4=rc5=1;
enable_interrupts(GLOBAL);
while(true)
{
if(xung1==10)
{
ra0=0;
}
else if(xung1==15)
{
ra0=1;
ra5=0;
}
else if (xung1==24)
{
ra0=ra5=1;
rb1=0;
}
}
}