View Single Post
Old 27-03-2007, 10:27 PM   #8
phamvanthang
Nhập môn đệ tử
 
Tham gia ngày: Sep 2006
Bài gửi: 7
:
dung CCP1 de tao song vuong voi PIC877a

Toi dang tim cach su dung che do CCP1 cua PIC877a tao ra song vuong, chuong trinh viet bang CCS C. Nhung chay mo phong bang Proteous thi lai thu duoc song co chu ki khong phai la 2 ms. Xin moi nguoi sua giup. Cam on!
Code:
#include <16F877.h>
#INCLUDE<def_877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

int16 pulse;

#int_ccp1
void isr()
{
      
   if (!bit_test(PORTB,0)){
   output_high(PIN_b0);
   }
   else{
   output_low(PIN_B0);}
   CCP_1+=1000;   
}



void main()
{
   CHAR VALUE;
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);   
   setup_ccp1(CCP_COMPARE_INT);
   enable_interrupts(INT_CCP1);
   enable_interrupts(GLOBAL);


   pulse = 1000;
   TRISB = 0;
   PORTB = 0;
   CCP_1 = PULSE;
   
   set_timer1(0);
       
   while(true);                       
}

thay đổi nội dung bởi: namqn, 28-03-2007 lúc 12:30 AM.
phamvanthang vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn