PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > RTOS và Thuật toán với 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

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
Prev Previous Post   Next Post Next
Old 10-05-2011, 09:54 PM   #6
tdm
Đệ tử 7 túi
 
Tham gia ngày: May 2005
Bài gửi: 258
:
Trích:
Nguyên văn bởi XuHi View Post
Anh có thể nói rõ hơn là mình sẽ ngắt gì không? Với lại để có thể thấy nhấp nháy cũng phải cần delay khoảng 150 ms, nhưng khi quét led 7 đoạn mỗi lần delay chỉ là 1 ms thôi, nếu chương trình chạy quet_led() liên tục mỗi lần chỉ delay rất nhỏ làm sao mắt thấy được.
Em có tham khảo code của anh Linhnc308:
Code:
      PortB=maled7[led3];
      if(blink_min==1)     RC2=1;//LED3
      else RC2=0;
      delay_ms(1);         RC2=1;
      PortB=maled7[led4];
      if(blink_min==1)     RD0=1;//LED4
      else RD0=0;
      delay_ms(1);         RD0=1;
Nhưng mà không dùng được?
đoạn code đơn giản để làm việc đó:
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);
}
File Kèm Theo
File Type: zip led_7.zip (14.1 KB, 56 lần tải)
__________________
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.
tdm 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à 08:53 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