PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Các ngôn ngữ lập trình khác (CCS C, HT PIC,...)

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Tìm Kiếm Bài Trong Ngày Ðánh Dấu Ðã Ðọc Vi điều khiển

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 04-07-2016, 12:33 PM   #21
tdmh.2508
Nhập môn đệ tử
 
Tham gia ngày: Apr 2016
Bài gửi: 1
:
em có code xuất tần số mà không hiểu đoạn này anh nào pro giúp mình với

//===========================
#int_ext
void dem_xung()
{
so_xung++;
}

#INT_TIMER1
void tao_tre_1s() // Trinh phuc vu ngat tran TIMER1
{
set_timer1(3036); //(65536-3036).1us.8=50 000us
count_t1++; //tran sau 500 000us=0.5us
if(count_t1==2) // 2*500 000=1s
{
tan_so = so_xung;
so_xung = 0;
count_t1 = 0;

}
}
//=====================

chương trình
#include <16f877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use fast_io(d)
#use fast_io(e)
#byte portd=0x08
#bit rs=0x09.0
#bit rw=0x09.1
#bit e=0x09.2
#bit rb0=0x06.0

int16 so_xung,tan_so,count_t1;
int16 tramnghin,chucnghin,nghin,tram,chuc,dv;
int16 u[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x3 9};


#int_ext
void dem_xung()
{
so_xung++;
}

#INT_TIMER1
void tao_tre_1s() // Trinh phuc vu ngat tran TIMER1
{
set_timer1(3036); //(65536-3036).1us.8=50 000us
count_t1++; //tran sau 500 000us=0.5us
if(count_t1==2) // 2*500 000=1s
{
tan_so = so_xung;
so_xung = 0;
count_t1 = 0;

}
}

void ghi_ir()
{
e=1;rs=0;rw=0;e=0;
delay_ms(3);
}
void ghi_dr()
{
e=1;rs=1;rw=0;e=0;
delay_ms(3);
}

void main()
{
{
set_tris_d(0);
set_tris_e(0b000);

enable_interrupts(global);
enable_interrupts(int_ext);
ext_int_edge (H_to_L);
enable_interrupts(INT_TIMER1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(3036);

portd=0x01;
ghi_ir();
portd=0x0c;
ghi_ir();
portd=0x38;// 2 dong
ghi_ir();

PORTD=0X80;
GHI_IR();
PORTD="T";
GHI_DR();
PORTD="a";
GHI_DR();
PORTD="n";
GHI_DR();
PORTD=" ";
GHI_DR();
PORTD="S";
GHI_DR();
PORTD="o";
GHI_DR();
PORTD=":";
GHI_DR();
}

while(1)
{
tramnghin=tan_so/100000;
chucnghin=(tan_so/10000)%10;
nghin=(tan_so/1000)%10;
tram=(tan_so/100)%10;
chuc=(tan_so/10)%10;
dv=tan_so%10;

portd=0x87;
ghi_ir();
portd=u[tramnghin];
ghi_dr();
portd=u[chucnghin];
ghi_dr();
portd=u[nghin];
ghi_dr();
portd=u[tram];
ghi_dr();
portd=u[chuc];
ghi_dr();
portd=u[dv];
ghi_dr();
portd="H";
ghi_dr();
portd="z";
ghi_dr();

}
}
tdmh.2508 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 

Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 06:58 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam