PIC Vietnam

Go Back   PIC Vietnam > falleaf

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

Conversation Between falleaf and leuvunam
Showing Visitor Messages 1 to 1 of 1
  1. leuvunam
    10-11-2009 09:51 AM
    leuvunam
    Em đang đọc encoder 100xung dùng Pic6f877a rồi gửi lên máy tính số xung đó.e viết mà bị lỗi ko hiểu tại sao.a xem giup e vơi!
    Chương trình của e như sau!
    #include <16f877a.h>
    #include <def_877a.h>
    #device *=16 ADC=8
    #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
    #use delay(clock=12000000)
    #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8)
    int8 elr2,dem2;
    int8 a,b;
    #INT_timer0
    void timer0_isr()
    {
    if(input(PIN_E1)==1)
    {
    elr2=elr2+1;
    }
    if(input(PIN_E1)==0)
    {
    elr2=elr2-1;
    }
    set_timer0(255);

    if(elr2==201)
    {
    dem2=dem2+1;
    elr2=100;
    }
    if(elr2==0)
    {
    dem2=dem2-1;
    elr2=100;
    }
    }
    void main()
    {
    a=0;
    b=0;

    elr2=100;
    dem2=100;

    trisb=0xff;
    trise=0xff;
    trisa=0xff;

    enable_interrupts (GLOBAL);
    enable_interrupts(INT_RTCC);//ngat timer 0
    setup_timer_0(rtcc_div_1|rtcc_ext_H_to_L);
    set_timer0(255);

    while (true)
    {
    if(input(PIN_B4)==1)
    {
    a=1;
    }
    else a=0;

    if(b==0 & a==1)
    {
    printf("%u \r",elr2);
    }
    b=a;
    }

    }
    Em cảm ơn anh nhiều
    A gửi vào mail cho e nhe!
    leu_vu_nam@yahoo.com.vn

Múi giờ GMT. Hiện tại là 01:28 AM.


Đượ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