Browsing this Thread:
1 Anonymous Users
|
Re: C30 CAN的Identifier及Data Length如何得到?
|
|
管理員
Joined
: 2004/4/28 19:29 最後登入時間
: 昨天 15:12
Group:
註冊會員 站務管理者
Level : 18 HP : 0 / 426 MP : 125 / 24919 EXP : 7
|
你好,
C30 的 CAN Library 寫得並不像 18F 的 AN738 那麼容易用 ! 所以再使用上必須要自己完成一些小工作.
1. 使用 CAN1IsRxReady(buff_no) 或 CAN2IsRxReady(buff_no) 來得知在 CAN 模組中是否有哪一個 Buffer 已經有資料進入了 . 例如 :
2. 若 Rx1_Status = CAN1IsRxReady(1) ; 得到的結果為 1 , 表示 CAN1 的 Buffer1 已收到有效資料 ! 此時先將C1RX1SID & C1RX1EID 讀出後再利用 CAN1ReceiveMessage ( rx_data , 5 , 1 ) 將資料讀至 rx_data .
第二個參數 "5" 是表示期望讀入的 Byte 數 . 第三個參數則指定要讀 Buffer0 or Buffer1.
3. 若是長度需要先知道 , 則要先讀取 C1RX0DLC or C1RX1DLC (如果用的是 CAN1 Module )
Regards,
發表於: 2006/5/11 18:28
|
|
|
C30 CAN的Identifier及Data Length如何得到?
|
|
新會員
Joined
: 2006/4/10 11:07 最後登入時間
: 2018/2/14 9:56
Group:
註冊會員
Level : 2 HP : 0 / 40 MP : 5 / 2142 EXP : 62
|
在C18中Identifier可由指令CANReceiveMessage中的unsigned long *id 得到,在C30中CAN1ReceiveMessage中沒有unsigned long *id ,Identifier要用何指令得到? 在DS51456C-page92中的最後1行 Code Example: CAN1ReceiveMessage(rx_data, 5, 0);指令中的5為datalen,0為MsgFlag, datalen 與 MsgFlag 是指令的條件值,還是指令執行完後,結果儲存的地方?
發表於: 2006/5/10 18:41
|
|
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.