Re: 請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
版主
|
1. 看一下 Timer.h 裡的定義:
/* Timer1 Control Register (T1CON) Bit Defines */
2. 看一下 C:\MCC18\doc\periph-lib\timer.htm 裡的說明,因為在 h 檔裡的定義關係,所以就要使用&做常數的運算:
Function:
發表於: 2008/6/27 14:44
|
|||
|
Re: 請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
資深會員
|
大家好:
OpenTimer0( TIMER_INT_OFF|T0_8BIT|T0_SOURCE_INT|T0_PS_1_32 ); Nop();//斷點一 OpenTimer0( TIMER_INT_OFF&T0_8BIT&T0_SOURCE_INT&T0_PS_1_32 ); Nop();//斷點二 我用軟體模擬時|不正確而&正確, 在timer.h中有一USE_OR_MASKS是要使用|或&功能, 而我不知該USE_OR_MASKS是在那一檔案已有define. 不知各位先進有何看法,煩請告知. Thanks.
發表於: 2008/6/26 9:44
|
|||
|
Re: 請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
資深會員
|
引言:<div class="xoopsQuote"><blockquote><br />jlian 寫到:<br />大家好:<br />我想我知道了,應該是一樣的結果,只是用&或|的方式而已.<br />當然&與|也應該不可混合使用才對吧!<br />Thanks.</blockquote></div><br /><br />兩者概念上就差很多了。單就邏輯觀念對應到單晶片來說。&是用來關閉某些東西,|是用來啟用某些東西。在C18函式庫中使用|就是把這些功能"Open"起來。<br /><br />你把函式定義的Marco用二進位表示來看就一目了然了。
發表於: 2008/6/24 20:00
|
|||
不要問我哪裡來,我只是個流浪天涯的工程師
|
||||
|
Re: 請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
資深會員
|
結果應該完全不一樣ㄛ
建議先開啟timer.h 把裡面各參數定義值看一下 應該就會明白為什麼要用 & 才對
發表於: 2008/6/24 17:32
|
|||
|
Re: 請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
資深會員
|
大家好:
我想我知道了,應該是一樣的結果,只是用&或|的方式而已. 當然&與|也應該不可混合使用才對吧! Thanks.
發表於: 2008/6/24 17:11
|
|||
|
請問C18函式的&與|有何不同?
|
||||
---|---|---|---|---|
資深會員
|
大家好:
OpenTimer0( TIMER_INT_OFF & T0_SOURCE_INT & T0_PS_1_32 ); OpenTimer0( TIMER_INT_OFF | T0_SOURCE_INT | T0_PS_1_32 ); 請問上面兩個這樣設到底有何差別? 煩請告知. Thanks.
發表於: 2008/6/24 16:40
|
|||
|