Thông báo

Collapse
No announcement yet.

các pro xem mình sao cho vào ccs báo lỗi

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • các pro xem mình sao cho vào ccs báo lỗi

    #include <16F877A.h>
    #include <def_877a.h>
    #device *=16 adc=10
    #FUSES NOWDT,HS,NOPUT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP, NOCPD,NOWRT
    #use delay(clock=20000000)
    #use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7, bits=9)
    #include <lcd_lib_4bit.c> // Thu vien ham cho LCD
    int8 low,high,key,mode,min,max,mode1,i;
    int1 do_F;
    void convert_bcd(int8 x);
    void bao_dong();
    void test();
    //-----------------------------------------------------------------
    void main()
    {
    float value;
    on_off =1;
    min =15; //nhiet do min default
    max =35; //nhiet do max default
    do_F =0 ;
    i = 50 ;
    mode =0 ;
    mode1 = 0 ;
    trisa = 0xFF;
    trisb = 0x01;
    trisd = 0x00;
    LCD_init();
    Printf(LCD_putchar,"Lop DT8 - BKHN");
    LCD_putcmd(0xC0);
    Printf(LCD_putchar,"Khoi tao...");
    // Khoi tao cho ngat ngoai
    enable_interrupts (INT_EXT);
    ext_int_edge(H_TO_L);
    enable_interrupts (GLOBAL);
    // Khoi tao che do cho bo ADC
    setup_adc_ports(AN0);
    setup_adc(ADC_CLOCK_INTERNAL);
    delay_us(10);
    // Lay mau nhiet do lan dau tien
    value=(float)read_adc();
    value = (value - 558.5)/2.048; // For 5V supply
    // value = (value - 754.8)/2.048; // For 3.7V Supply
    // value = (value - 698.2)/2.048; // For 4V supply
    convert_bcd((int8)value); // Tach so tram, chuc, donvi de hien thi len LED 7
    delay_ms(1000);
    LCD_putcmd(0xC0);
    Printf(LCD_putchar,"Khoi tao xong");
    while(1)
    {
    if (i==50)
    {
    value = read_adc();
    value=(value-558.5)/2.048;
    if (do_F==1) value=1.8*value+32;
    convert_bcd((int8)value);
    printf("\n\rNhiet do phong: %u",value);// Gui gia tri len may tinh
    LCD_putcmd(0xC0);
    printf(LCD_putchar," Temp = ");
    LCD_putchar(high); LCD_putchar(low);
    if (do_F==0) printf(LCD_putchar," C");
    else printf(LCD_putchar," F");
    i=0;
    }
    i++;
    if(((int8)value > 40) || ((int8)value < 15)) on_off=1;
    else
    {
    on_off = 0;
    LCD_Putcmd(0xCF);
    LCD_putchar(" ");
    blink=0;
    }
    if (on_off==1)
    {
    if (blink==0) {
    LCD_Putcmd(0xCF);LCD_putchar("!");blink=1;delay_ms (250);}
    else {LCD_Putcmd(0xCF);LCD_putchar(" ");blink=0;delay_ms(250);}
    }
    }
    }//end main-----------------------------------------------------------
    #INT_EXT
    void test()
    {
    if (do_F == 1) do_F=0;
    else do_F=1;
    }
    void convert_bcd(int8 x)
    {
    low=x%10; //chia lay phan du, so hang don vi
    high=x/10; //tach hang tram va hang chuc
    low = low + 0x30;
    high = high + 0x30;
    }
    void bao_dong(){
    int8 i;
    if (blink == 0) blink = 1;
    else blink=0;
    for(i=0;i<50;i++)
    {
    LCD_Putcmd(0xCF);
    if (blink==0) LCD_putchar("!");
    else LCD_putchar(" ");
    }
    }
    nó cứ báo lỗi khi dịch ccs nản các bạn xem ntn cái

Về tác giả

Collapse

chelseaboy Tìm hiểu thêm về chelseaboy

Bài viết mới nhất

Collapse

Đang tải...
X