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 25-07-2012, 11:48 AM   #1
minh_thanh
Nhập môn đệ tử
 
Tham gia ngày: Apr 2009
Bài gửi: 3
:
Lỗi ccs timer2 pic 16f886

Mình đang lập trình quét led 7 thanh bằng timer2
file mô phỏng trong file đính kèm.
trong đoạn code in đậm khi hiển thị led 7thanh tham số "gio_dvi" cứ tăng lên đến 4 thì lại reset lại =0; trong khi ý đồ lập trình của mình là nó phải tăng lên đến 9 rồi mới reset lại =0;
code như sau:


#include <16F886.h>
#device adc=8

#FUSES WDT //Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPD //No EE protection
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES NOPUT //Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=4000000)
#use fast_io(B)
#use fast_io(A)
#use fast_io(C)
Unsigned char Ma_led[10]={0x05,0xDD,0x46,0x54,0x9C,0x34,0x24,0x5D,0x04,0x1 4};
Unsigned char Ma_ledc[10]={0x01,0xD9,0x42,0x50,0x98,0x30,0x20,0x59,0x00,0x1 0};
int8 giay,phut,sau_phut,gio_dvi,gio_chuc,gio_tram,dem;
//int16 dem;
#int_TIMER2
Void Dinh_thoi()
{
dem++;
while(dem==10)
{
if(sau_phut<10){sau_phut++;dem=0;}
else
{
sau_phut=0;
if(gio_dvi<10){gio_dvi++;}
else {gio_dvi=0;}



}
}
////////////////////Quet 3 led, gio hien tai/////////
///////////////////Quet led 1% gio(LED23)////////////////
output_C(0xFC);
output_B(Ma_led[sau_phut]);
delay_us(2800);
///////////////////Quet led hang gio(Led22)///////////
output_C(0xFB);
output_B(Ma_ledc[gio_dvi]);
delay_us(2800);
///////////////////Quet led hang chuc gio(Led21)///////////
output_C(0xF7);
output_B(Ma_led[gio_chuc]);
delay_us(2800);
/////////////////////Quet 4 led, gio tong///////////
////////////////////////////////////////////////////////////
////////////////////quet led hang 1% gio/////////////
output_C(0x7F);
output_B(Ma_led[sau_phut]);
delay_us(2800);
//////////////////quet led hang gio/////////////////
output_C(0xBF);
output_B(Ma_ledc[gio_dvi]);
delay_us(2800);
///////////////////Quet led hang chuc gio//////////////////
output_C(0xDF);
output_B(Ma_led[gio_chuc]);
delay_us(2800);
//////////////////Quet led hang tram gio//////////
output_C(0xEF);
output_B(Ma_led[gio_tram]);
delay_us(2800);

}


void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1 (T1_DISABLED);
setup_timer_2(T2_DIV_BY_16,124,10);
setup_oscillator(False);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
set_tris_A(0x00);
set_tris_B(0x00);
set_tris_C(0x00);
sau_phut=0;gio_dvi=0;gio_chuc=0;gio_tram=0;dem=0,g iay=0;phut=0;
while(1)
{
}
}

Rất mong ae chỉ giáo!!!!!
Xin chân thành cảm ơn.
File Kèm Theo
File Type: zip dd.zip (16.7 KB, 0 lần tải)
minh_thanh 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à 03:41 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