View Single Post
Old 04-01-2013, 09:40 PM   #4
thucdontinhyeu_
Nhập môn đệ tử
 
Tham gia ngày: Dec 2012
Bài gửi: 1
:
pro giúp mình sửa lỗi code đo chu kì xung píc6f877a

#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use fast_io(b)
#use fast_io(d)
#use fast_io(e)
#BYTE portb=0x6
#BYTE portd=0x8
#BYTE porte=0x9
#bit b7=portb.7
int8 a[3]={0x01,0x38,0x0E};
int16 n,p;
int8 t,tam,i,k;
void xuatlcd();
void khoitao();
void ngat();
#INT_CCP1
void ngat()
{
k=1;
t=0;
}
void main()
{
enable_interrupts(int_CCP1);
enable_interrupts(GLOBAL);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
setup_ccp2(CCP_CAPTURE_RE);
setup_ccp1(CCP_CAPTURE_FE);
set_timer1(0);
SET_TRIS_c(0b01111111);
SET_TRIS_e(0);
SET_TRIS_d(0);
for (i=0;i<=2;i++)
{
tam=a[i];
khoitao();
}
while(1)
{
if(input(pin_c1)&&t==0)
{
set_timer1(0);
t++;
k=0;
}
if(k==1)
{
n=CCP_2;
p=(n*0.8)/58;
tam=0x80;
khoitao();
tam=(p/100)+48;
xuatlcd();
tam=(p%100)/10+48;
xuatlcd();
tam=(p%100)%10+48;
xuatlcd();
t=0;
}
}
}
void khoitao()
{
porte=0b100;
portd=tam;
porte=0b000;
delay_ms(20);
}

void xuatlcd()
{
porte=0b101;
portd=tam;
porte=0b001;
delay_ms(20);
}
File Kèm Theo
File Type: rar 6.rar (13.8 KB, 7 lần tải)
thucdontinhyeu_ vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn