View Single Post
Old 28-05-2007, 08:46 AM   #75
tranvanthuong
Đệ tử 2 túi
 
Tham gia ngày: Mar 2007
Bài gửi: 45
:
chương trình em viet đề điều khiển 4 led chớp tắt và dùng ngắt RB để kết hợp điều chỉnh tốc độ không biết tại sao chương trình không chạy rồi có khi chạy rút nguồn ra ghim lại thì chương trình không chay nhờ các anh chỉ giúp
chương trình em viet như sau:
Code:
include "E:\ccs c\chuong_trinh_ccsc\banh_kem_duc_thanh\chuong_trinh.h"
#int_RB
RB_isr()
{
int8 y;
  disable_interrupts(INT_RB);
  disable_interrupts(GLOBAL);
  
  if ( input(PIN_B6) )         //tang gia tri trong o nho
     {
       y = read_eeprom(0x00);
       y = y + 20;
       write_eeprom (0x00,y);
     }

 if ( input(PIN_B7) )          //giam gia tri trong o nho
    {

       y = read_eeprom(0x00);
       y = y - 20;
       write_eeprom (0x00,y);
      }
   
    delay_ms(1000);
    
    enable_interrupts(GLOBAL);
    enable_interrupts(INT_RB);
    
}
//===========CAC CHUONG TRINH CON==============



void tao_tre(int16 x);




//============================================



void main()
{ int8 x=10,y;


   output_B(0x00);
   output_A(0x00);
   enable_interrupts(INT_RB);
   enable_interrupts(GLOBAL);




   while(1)
    {
      output_high(pin_B0);
      tao_tre(1);
      output_low(pin_B0);
      tao_tre(1);

      output_high(pin_B1);
      tao_tre(1);
      output_low(pin_B1);
      tao_tre(1);

      output_high(pin_B2);
      tao_tre(1);
      output_low(pin_B2);
       tao_tre(1);

      output_high(pin_B3);
      tao_tre(1);
      output_low(pin_B3);
      tao_tre(1);

      output_low(pin_B0);
      output_low(pin_B1);
      output_low(pin_B2);
      output_low(pin_B3);
      tao_tre(1);

      output_high(pin_B0);
      output_high(pin_B1);
      output_high(pin_B2);
      output_high(pin_B3);
      tao_tre(1);

      output_low(pin_B0);
      output_low(pin_B1);
      output_low(pin_B2);
      output_low(pin_B3);
      tao_tre(1);


    }
}
//============================================

void tao_tre(int16 x)
   {
        int16 z,i;

        z = x + read_eeprom (0x00);
          delay_ms(100);
         for(i=0;i<z;++i)
          delay_ms(2);

   }

//===========================================
và file.h
#include <16F84A.h>

#FUSES NOWDT,NOPUT,PROTECT                 	//No Watch Dog Timer
#FUSES HS
#use delay(clock=10000000)
__________________
Cổng trường Đại học cao vời vợi
Đồng ruộng mênh mong đón em về!

thay đổi nội dung bởi: falleaf, 28-05-2007 lúc 08:55 AM.
tranvanthuong vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn