Keil Logo

定期的なメッセージの送信


シグナル関数を使用して、ユーザアプリケーションにメッセージを定期的に送信できます。シグナル関数は、µVision4 デバッガ内で作成されます。このトピックの詳細については、µVision4 の「デバッグ関数」を参照して下さい。以下のシグナル関数は、2 バイトのメッセージを毎秒 10 回送信します。シグナル関数は、アプリケーションプログラムに送信された情報値を受信します。この情報値は、継続的に増加します。

SIGNAL void sendCAN (unsigned int info)  {
 while (1)  {
    CAN0ID = 0x4510;          // CAN message ID
    CAN0L  = 2;               // message length 2 bytes
    CAN0B0 = (info & 0xFF);   // message data byte 0
    CAN0B1 = (info >> 8);     // message data byte 1
    CAN0IN = 2;               // send CAN message with 29-bit ID
    twatch (CLOCK / 10);      // send message 10 times per second
    info++;                   // increment info value
  }
}

>sendCAN (500);    // invoke sendCAN function
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.