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 15-01-2008, 08:22 AM   #12
Jerry
Đệ tử 5 túi
 
Jerry's Avatar
 
Tham gia ngày: Sep 2006
Bài gửi: 100
:
- Em tưởng biến isr_count em khai báo ngay từ đầu thì nó là biến toàn cục, dùng trong hàm nào cũng được??

- Em sửa lại chương trình thế này nhưng vẫn chưa chạy được:

Code:
#include <16F877A.h>
#include <def_877a.h>
#device *=16 adc=10
#FUSES NOWDT, XT, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=4000000)
#use fast_io (b)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

#define OK PIN_B6
#define Cancel PIN_B7

#define OK_PRESSED  !input(OK)

#include <lcd_lib_4bit.c>

   int8 count;
   char phim;
   int8 isr_count,press;

#int_TIMER0
void interrupt_timer0()
{
   if(OK_PRESSED)
   {
      isr_count++;
      if(isr_count==81)
      {
         isr_count=0;
         press=1;
         disable_interrupts(GLOBAL);
         disable_interrupts(INT_TIMER0);
      }
   }
   else
   {
      press=0;
      disable_interrupts(GLOBAL);
      disable_interrupts(INT_TIMER0);
   }
}

//-----------------------------------------------------------------

void main(void)
{
   press=0;
   output_b(0xC0);
   set_tris_a(0xC0);
   set_tris_b(0xC1);
   port_b_pullups (TRUE);

   LCD_init();
   delay_ms(500);
   LCD_putcmd(0x80);
   Printf(LCD_putchar,"Hi ev'body");   //Hien thi man hinh 1
   LCD_putcmd(0xC0);
   Printf(LCD_putchar,"Khoi tao...");

   if(OK_PRESSED)
   {           //enable timer0
      set_timer0(6);
      setup_timer_0(RTCC_INTERNAL);
      enable_interrupts(INT_TIMER0);
      enable_interrupts(GLOBAL);
   }
   while(press!=1) {}
      LCD_putcmd(0x01);    //xoa man hinh
      LCD_putcmd(0x80);
      Printf(LCD_putchar,"Enter Pressed");  //Hien thi man hinh 2

}
Bây giờ nó chỉ hiển thị màn hình đầu tiên
Hi ev'body
Khoi tao...
Bấm phím ko thấy xi nhê gì.
__________________
Do more than exist, LIVE

thay đổi nội dung bởi: Jerry, 15-01-2008 lúc 08:59 AM.
Jerry 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à 05:01 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