Code:
#include <16F877a.h>
#INCLUDE<def_877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
int16 pulse;
//#int_ccp1
#int_ccp2
void isr()
{
if (!bit_test(PORTB,0))
{
output_high(PIN_B0);
}
else
{
output_low(PIN_B0);
}
// CCP_1+=1000;
CCP_2+=5000;
}
void main()
{
// CHAR VALUE;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_ccp2(CCP_COMPARE_INT);
enable_interrupts(INT_CCP2); //-> Cho phep ngat
enable_interrupts(GLOBAL);
pulse = 5000;
TRISB = 0;
PORTB = 0;
// CCP_1 = PULSE;
CCP_2 = PULSE;
// set_timer1(0);
set_timer1(0);
while(true);
}
Bạn thử cái này xem thế nào