View Single Post
Old 08-05-2016, 01:57 PM   #1
langkhachpfiev
Nhập môn đệ tử
 
Tham gia ngày: May 2016
Bài gửi: 1
:
Arrow [cần giúp gấp] P16f877A interrupt Rb0 (press & hold SW)

yêu cầu: (only use interrupt rb0)
1.press SW (not hold) ,count and display number of times of press (if up to 19 begin down,example 0,1,...18,19,18,17,...1,0,1,2....continue)--->solved
2.press and hold SW,count will up/down and display continuous--->mình không biết giải quyết như thế nào (trong hàm void ngat_RB0() hay trong void main() ?)

Code C file (PICC) and simulation (protues 8.4)
http://www.mediafire.com/download/3o...est_rb0_SW.rar




phần code của mình,chạy tốt yêu cầu 1:
Trích:
#include <16F877A.h>
#fuses xt
#use delay(clock=4000000)
int8 ma7seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
int8 count,i,n;

#int_ext
void ngat_RB0()
{

i=i+1;


}




void display()
{

if(i==19)
{i=0;n=n+1;}
if(n%2==0)
{count=i;}
else
count=19-i;


output_d(ma7seg[count/10]);
output_low(pin_e0);
delay_ms(25);
output_high(pin_e0);

output_d(ma7seg[count%10]);
output_low(pin_e1);
delay_ms(25);
output_high(pin_e1);

}


void main()
{
i=0;
n=0;
count=0;
set_tris_e(0x00);
set_tris_b(0x01);
set_tris_d(0x00);
output_e(0xff);
output_d(0x00);


enable_interrupts(global);
enable_interrupts(int_ext);
ext_int_edge(H_to_L);




while(1)
{
display();
}
}
langkhachpfiev vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn