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 Bài Trong Ngày Vi điều khiển

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 02-04-2011, 11:23 PM   #1
foremostpirate
Nhập môn đệ tử
 
Tham gia ngày: Jan 2011
Bài gửi: 7
:
Post Cần giúp sửa lỗi code

Em mới học PIC, em viết đoạn code nay chưa chạy nhưng không hiểu nguyên nhân mong các anh giúp đỡ.
#include <16f877a.h>
#include <def_877a.h>
#device *=16 ADC=8
#FUSES NOWDT,HS,NOPUT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP
#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
//Khai bao ham
void dkdcbuoc();
unsigned int16 count;
#INT_EXT
void EXT_ngat()
{
output_C(0x01);
delay_ms(1000);
dkdcbuoc();
count=0;
}
//Chuong trinh ngat TMR0
#int_timer0
void interrupt_timer0()
{
set_timer0(6);
++count;
if(count == 20000) // 20000*500us = 1000000us = 10s
{
count=0;
output_C(0x00);
}
}
void main(void)
{
SET_TRIS_A(0x00);
SET_TRIS_B(0xff);
SET_TRIS_C(0x00);
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
ext_int_edge(0,H_to_L);
PORT_B_pullups(1);
enable_interrupts(int_timer0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
set_timer0(6);

output_C(0x01);
}

void dkdcbuoc()
{
SET_TRIS_A(0x00);
SET_TRIS_C(0x00);
unsigned int16 i;
unsigned int8 goc;
CONST unsigned quayT[4]={0x01,0x04,0x02,0x08};
CONST unsigned quayN[4]={0x08,0x02,0x04,0x01};
i=0;
for(goc=0;goc<=50;goc++) //Dong co quay thuan
{
output_A(quayT[i]);
delay_ms(200);
i++;
if(i==4)
{
i=0;
}
}
delay_ms(1000);
i=0;
for(goc=0;goc<=51;goc++) //Dong co quay nghich
{
output_A(quayN[i]);
delay_ms(200);
i++;
if(i==4)
{
i=0;
}
}

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


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:24 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