View Single Post
Old 14-08-2008, 05:46 PM   #14
minhdt10
Đệ tử 1 túi
 
Tham gia ngày: May 2008
Bài gửi: 18
:
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
minhdt10 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn