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 21-02-2011, 01:28 PM   #13
ElecTel
Đệ tử 2 túi
 
Tham gia ngày: Jan 2011
Bài gửi: 36
:
bạn ơi sao mình copi code của bạn để biên dịch ra file hex được rồi mà khi mô phỏng trên protuer nó chẳng ra gì cả??? ko biết protues co bị gì ko mình sử dụng v7.6 SP4???

Code:
#include <16F877A.h>
#device *=16 adc=10
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=4000000)
#include <lcd.c>
#define LCD_DATA_PORT getenv("SFR:PORTD")  
#define LCD_ENABLE_PIN  PIN_D0                                    ////
#define LCD_RS_PIN      PIN_D1                                    ////
#define LCD_RW_PIN      PIN_D2    
#define LCD_DATA4       PIN_D4                                    ////
#define LCD_DATA5       PIN_D5                                    ////
#define LCD_DATA6       PIN_D6                                    ////
#define LCD_DATA7       PIN_D7                                    ////
#byte   portB =0x06                                ////
#bit B1= portB.1                         ////
#bit B2= portB.2                                ////
void push_key(void);
main()
{
set_tris_b(0b00000110);
port_b_pullups(true); 
set_tris_c(0b00000000);
lcd_init();
         lcd_gotoxy(1,1);     // cot 1 hang 1
         lcd_putc("Menu controler");
         lcd_gotoxy(1,2);
         lcd_putc("K=");
 while(1)
 {
 push_key();
 }
}
void push_key()
      {
          int count;
           if(B1==0) //nut o chan B1 duoc nhan
         {
             delay_ms(10);      //delay qua xung nhieu
            while(B1==0)    //cho den khi tha
            {;}
             count++;   //dem so lan bam nut
             
            lcd_gotoxy(3,2);
            lcd_putc("   ");
            lcd_gotoxy(3,2);
            Printf(LCD_putc,"%u",count); //  hiển thị số count đếm lên LCD
             delay_ms(10);      //delay qua xung nhieu  
           }
            
            
         
            else if(B2==0)    //nut o chan b2 duoc nhan
         {
             delay_ms(10);
            while(B2==0)
            {;}
             count--;   //dem so lan bam nut
            lcd_gotoxy(3,2);
            lcd_putc("   ");//
            lcd_gotoxy(3,2);
            Printf(LCD_putc,"%u",count);  //  hiển thị số count đếm lên LCD
             delay_ms(10);      //delay qua xung nhieu
             }
                  else
         {
         }
    }
ElecTel 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à 09: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