![]() |
|
Tài trợ cho PIC Vietnam |
||||||||
| RTOS và Thuật toán với PIC RTOS và Các thuật toán dùng cho PIC/dsPIC/PIC32 Mod: phamminhtuan |
|
|
Ðiều Chỉnh | Xếp Bài |
|
|
#6 | |
|
Đệ tử 7 túi
Tham gia ngày: May 2005
Bài gửi: 258
: |
Trích:
Code:
#include <16F877A.h>
#Fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#use fast_io(c)
#use fast_io(d)
const unsigned char font[]= {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90 };
int8 i=0,a,tao_nhay=0xaa;
int16 count=0;
void hien_thi(void);
void hien_thi_1(void);
#int_timer0
void interrupt_timer0()
{
set_timer0(6);
++count;
if(count == 5000) //
{
count=0;
tao_nhay=~tao_nhay;
}}
void main ()
{
set_tris_b(0);
set_tris_d(0);
output_b(0x00);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
set_timer0(6);//
enable_interrupts(int_timer0);
enable_interrupts(global);
while(1)
{
if(tao_nhay==0xaa)
{
hien_thi();
}
else
{
hien_thi_1();
}
}
}
void hien_thi(void)
{
output_d(0xfe);
output_b(font[i/10]);
delay_ms(1);
output_b(0xff);
output_d(0xfd);
output_b(font[i%10]);
delay_ms(1);
output_b(0xff);
}
void hien_thi_1(void)
{
output_d(0xfe);
output_b(font[i/10]);
delay_ms(1);
output_b(0xff);
output_d(0xfd);
delay_ms(1);
output_b(0xff);
}
__________________
viết chương trình cho vdk chạy ổn định là cả một vấn đề. thay đổi nội dung bởi: tdm, 10-05-2011 lúc 10:01 PM. |
|
|
|
|
|
|