5 years, 7 months ago.

CAN 通信プロトコルの実際について

LPC1768のCANに使用できるピン(P29,P30)に、CANドライバMCP2551を接続し、CAN通信をしたく。

CANは、「送信時にエラーがあると、自動でリトライをする」など、通信プロトコルがあると思いますが、 それらのプロトコルは、どこの部分が担っているのでしょうか。

1、mbed内の送信プログラムに、自分でエラー検知、再送処理、などを書き込んで構築する 2、mbedのCAN.hライブラリの、CAN::write();機能に搭載されていて、勝手に実行される。 3、mbedのCPUに搭載されているコントローラが勝手に実行するため、ユーザープログラムでは意識する必要はない。 4、mbed基板の外の、ドライバICなどが勝手に実行するため、ユーザープログラムでは意識する必要はない。

以上 よろしくお願いします。

1 Answer

5 years, 7 months ago.

こんにちは健太さん、

CANプロトコルは、CPUや他のハードウェアコントローラ(UART、I2C、SPIなど)とともにマイクロコントローラのチップにインストールされるCANコントローラ(ハードウェアコンポーネント)に組み込まれています。 CPUは、CANコントローラとレジスタおよびバッファ(CANコントローラに属します)を介して通信します。しかし、CANバス上の通信は、CANコントローラによって完全に実現されています。これには、アービトレーションとエラー処理も含まれます。したがって、送信中にエラーが発生した場合、CANコントローラは自動的にメッセージを再送信します(設定されている場合)。 CPUは集中していません。しかし、CPUにはそのようなエラーが通知されるため、プログラム設計者は決定した場合に高いレベルで行動することができます。 MBEDは、CANコントローラ(CAN API /ドライバ)の設定と処理を簡素化するための高水準の機能を提供します。したがってCANバスを介した通信が可能になります。これは非常に簡単な説明でした。より詳細な情報を得るには、例えば、次のような参考文献を見てみることをお勧めします。

LPC176xユーザーマニュアルまたは
STM32F4xxリファレンス・マニュアルを参照してください。

私の日本語には申し訳ありません(Google翻訳)。私の答えは英語でも下にあります。

Hello Kenta-san,

The CAN protocol is built into the CAN controller (a hardware component), which is installed on the microcontroller's chip along with the CPU and other hardware controllers (like UART, I2C, SPI etc.). The CPU communicates with the CAN cntroller over registers and buffers (they belong to the CAN controller). But communication on the CAN bus is completely realised by the CAN controller. This includes also arbitration and error handling. So if there is an error during transmission the CAN controller re-transmits the message automatically (if it was configured so). The CPU is not envolved. However, the CPU can be informed about such errors so the program designer has an option to take actions on high level if he/she decides so. MBED provides a set of high level functions to simplify the configuration and handling of a CAN controller (CAN API/driver) and hence communication over a CAN bus. This was a very brief explanation. To get more details I would suggest to have a look at some reference mauals, like for example:

Chaper 16 in the LPC176x User Manual
Chapter 32 of the STM32F4xx Reference Manual.

Accepted Answer

ドライバIC、端末抵抗、通信相手、などと接続したらCAN通信ができました。ありがとうございます。

posted by Kenta Yasuda 21 Dec 2018