線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1261
推到 Plurk!
推到 Facebook!

C語言 旗標的問題一問

答題得分者是:暗黑破壞神
marcowing
一般會員


發表:3
回覆:3
積分:1
註冊:2004-11-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-11 18:44:18 IP:61.229.xxx.xxx 未訂閱
請問各位大大 我大致打一下我的程式喔 void open(void) 我有2組驅動碼table_1()=a,b,c,e { table_2()=e,c,b,a(驅動碼只是大概打一下) char i b=0-----我先把旗標歸零 if key==0 if b==0--當我旗標為零時 for(i=0;i<=3;i ) {p1=table_1(i)---因為key=0 我用第一組 delay; step=0 step { elsif key==1 if b==0--當我旗標為零時 for(i=0;i<=3;i ) {p1=table_2(j)---這邊是key=1我用第2組 delay; step=0 step { { { 請問一下 當我一開始判斷key=0 or1 近去他底下的for那我希望會依值循環 step一直累加直到--- 當我旗標便成1的時候 我的旗標事外面近來的 平時0 當按一下才會變1 我希望他跳離這個void open 往下依個去坐 我要怎麼改 我乃尾巴
------
我乃尾巴
marcowing
一般會員


發表:3
回覆:3
積分:1
註冊:2004-11-05

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-11 18:47:28 IP:61.229.xxx.xxx 未訂閱
對了 我的key是會一直改變的 他算是依個回授訊號 我乃尾巴
------
我乃尾巴
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-11 22:28:30 IP:221.169.xxx.xxx 未訂閱
引一段 C++Builder 的 help 給你看一下。
Syntax    volatile  ;    Description    Use the volatile modifier to indicate that a variable can be changed by a background routine, an interrupt routine, or an I/O port. Declaring an object to be volatile warns the compiler not to make assumptions concerning the value of the object while evaluating expressions in which it occurs because the value could change at any moment. It also prevents the compiler from making the variable a register variable    volatile int ticks;    void timer( ) {
   ticks  ;
}
void wait (int interval) {
   ticks = 0;
   while (ticks < interval);  // Do nothing    }    The routines in this example (assuming timer has been properly associated with a hardware clock interrupt) implement a timed wait of ticks specified by the argument interval. A highly optimizing compiler might not load the value of ticks inside the test of the while loop since the loop doesn急 change the value of ticks.    Note:        C   extends volatile to include classes and member functions. If you?e declared a volatile object, you can use only its volatile member functions.
這就像你在 主程式中只是一直等到 FLAG 的改變。 而FLAG的改變是由中斷那邊的ISR來改變時。 我們的 FLAG 要在宣告時,加上 volatile 這個字在最前面。
系統時間:2024-04-26 4:17:08
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!