![]() |
|
|
#1 |
|
Nhập môn đệ tử
Tham gia ngày: Feb 2008
Bài gửi: 5
: |
Code:
#include "C:\Documents and Settings\tungdinh's computer\My Documents\timer0\ff.h"
#use fast_io(c)
#use fast_io(a)
int dem;
#int_TIMER1
TIMER1_isr()
{
if (pin_A4)
{
dem++;
}
set_timer1(1000);
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
set_timer1(1000);
set_tris_c(0);
set_tris_a(0b111111);
output_high(pin_c1);output_high(pin_c2);
dem=0;
while(dem<5)
{
}
output_low(pin_c1);output_low(pin_c2);
// TODO: USER CODE!!
}
thay đổi nội dung bởi: namqn, 16-03-2008 lúc 03:13 AM. |
|
|
|
|
|
#2 |
|
Đệ tử 4 túi
Tham gia ngày: Mar 2007
Nơi Cư Ngụ: Da Nang
Bài gửi: 69
: |
Bạn nên cho biết rõ yêu cầu của đề tài. Đoạn code trên sau khi reset thì c1=c2=1, khi cho A4 = 1 một khoảng thời gian bằng 4 hoặc 5 lần ngắt timer1 gì đó thì c1 và c2 = 0
Đoạn code Timer1_isr() sửa lại như sau: Code:
#int_TIMER1
TIMER1_isr()
{
if (input(pin_A4)) // sửa ở đây
{
dem++;
}
set_timer1(1000);
}
thay đổi nội dung bởi: namqn, 16-03-2008 lúc 09:58 PM. |
|
|
|
![]() |
|
|