Browsing this Thread:
1 Anonymous Users
|
請教一個CAN的問題
|
|
初級會員
Joined
: 2009/4/3 17:21 最後登入時間
: 2010/6/30 19:42
Group:
註冊會員
Level : 3 HP : 0 / 60 MP : 7 / 2737 EXP : 41
|
請教各位先進,我在使用C30 Library撰寫CAN Function遭遇到一個問題。 我需要從CAN BUS上讀取兩個ID的資料,其ID分別為0x0b9 及0x0bc,並使用CAN1SetFilter function
CAN1SetFilter ( (char) 0 , CAN_FILTER_SID( 0x0b9 ) & CAN_RX_EID_DIS ,CAN_FILTER_EID( 0x00 )) ;
CAN1SetFilter ( (char) 1 , CAN_FILTER_SID( 0x0bc) & CAN_RX_EID_DIS ,CAN_FILTER_EID( 0x00 )) ;
由於,此function第一個引數為filiter no. 於是我選擇RXF0 與RXF1,而這兩個filiter都會將ID分別為0x0b9 及0x0bc的資料放進去RXB0的Buffer裡。於是我在主程式所撰寫的取出資料程式如下
if(CAN1IsRXReady(0)) //receieve from buffer0 { CAN1ReceiveMessage( RxData,8,0 ); data1 = RxData[0] ; data2 = RxData[1] ; .....
C1RX0CONbits.RXFUL=0; } 因為資料都是在RXB0,而我又有兩個ID的資料要讀出來,這樣在讀取的時候要如何做判斷現在是哪一個ID的資料?? 請各位先進幫幫我解決這疑問,拜託了!!謝謝~
發表於: 2009/10/14 14:18
|
|
You can view topic.
你 不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.