---
# System prepended metadata

title: f28335 can 學習筆記 BY 燒餅

---

# f28335 can 學習筆記 BY 燒餅
[程式原文作者](https://wenku.baidu.com/view/b81621136529647d272852b2.html?from=search)
如有侵權 立即刪文 使用以上程式做測試
以下是cana傳送 canb接收的程式 測試
 - 使用 500kps bit-rate
 - sp=0.6
 - sysclack 150MHz

```c
  ECanaMboxes.MBOX25.MDL.all = 0x00000000;
   ECanaMboxes.MBOX25.MDH.all = 0x00000000;//存储CAN消息的数据域 要傳神麼訊息都在這
```

```c
       do
       {

           ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
       } while(ECanaShadow.CANTA.bit.TA25 == 0 );   // Wait for TA5 bit to be set..
       //發送應答寄存器 消息成功發送則為1
```

```c
    struct ECAN_REGS ECanbShadow;
    /*write to the MSGID field*/
    ECanbMboxes.MBOX26.MSGID.all=0x95555555;//extend identifier
    /*configure mailbox under test as a transmit mailbox*/
    ECanbShadow.CANMD.all = ECanbRegs.CANMD.all;
    ECanbShadow.CANMD.bit.MD26 = 1;//CAN26MAIL 為接收郵箱
    ECanbRegs.CANMD.all = ECanbShadow.CANMD.all;
    /*enable mailbox under test*/
    ECanbShadow.CANME.all=ECanbRegs.CANME.all;
    ECanbShadow.CANME.bit.ME26 = 1;//郵箱激活 26被激活維郵箱Ram模式
    ECanbRegs.CANME.all = ECanbShadow.CANME.all;
    /*WRITE TO DLC FIELD IN MASTER CONTROL REG*/
    ECanbMboxes.MBOX26.MSGCTRL.bit.DLC=8;
```

![在这里插入图片描述](https://img-blog.csdnimg.cn/20200229121016187.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3phYzk2OTY=,size_16,color_FFFFFF,t_70)
上面是canalyst輸出的波型
下面則是F28335波型
請打開can後 更改 can setting 資料如下
其
 
 
 - 500kps bit-rate
 - sp 0.611 此項要與F28335誤差接近於1%
 - sysclock 16MHz

![在这里插入图片描述](https://img-blog.csdnimg.cn/2020022912110842.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3phYzk2OTY=,size_16,color_FFFFFF,t_70)
用canb接收時 要把與cana連線斷開
cana canb的can clock 要同時改成如下圖
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200229121610309.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3phYzk2OTY=,size_16,color_FFFFFF,t_70)
計算f28335 can時鐘 網站
[can時鐘](https://wenku.baidu.com/view/115a6ca49ec3d5bbfd0a74c7.html?from=search)
## 測試結果
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200229121843808.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3phYzk2OTY=,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200229122735707.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3phYzk2OTY=,size_16,color_FFFFFF,t_70)
