佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1693|回复: 0

CCS Interrupt 问题

[复制链接]
发表于 19-12-2009 11:22 PM | 显示全部楼层 |阅读模式
我的目的是要当input = 1 时 ,output  =
  1. output_high(PIN_B1);
  2.                         output_high(PIN_B2);
  3.                         delay_ms(25000);
  4.                         output_high(PIN_B1);
  5.                         output_low(PIN_B2);
  6.                         delay_ms(5000);
复制代码

当input = 0 时,output =
  1. output_high(PIN_B1);
  2. output_low(PIN_B2);                     
复制代码

如果现在input=1 而output 正在走着时
input state忽然间变0 了
我要output 直接跳去input =0 的output
请问我的code 那里出了问题
因为我test run 时 。。result 并非我expect 的
谢谢
  1. #include "16f84a.h"
  2. #use delay (clock=10000000)

  3. #int_ext // Interrupt name
  4. void isrext() // Interrupt service routine
  5. { output_high(PIN_B1);
  6.   output_low(PIN_B2);
  7. }

  8. void main ()
  9. {
  10.         enable_interrupts(int_ext); // Enable named interrupt
  11.         ext_int_edge(H_TO_L); // Interrupt signal polarity

  12.         while(1)
  13. {
  14.                 if( input(PIN_B0)==1)
  15.                       {
  16.                         output_high(PIN_B1);
  17.                         output_high(PIN_B2);
  18.                         delay_ms(25000);
  19.                                                 output_high(PIN_B1);
  20.                         output_low(PIN_B2);
  21.                         delay_ms(5000);
  22.                                                 continue;

  23.                         }
  24.                 else  
  25.                       {
  26.                         output_high(PIN_B1);
  27.                         output_low(PIN_B2);
  28.                        
  29.                        }


  30. }

  31. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 18-4-2024 08:12 PM , Processed in 0.060583 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表