This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F280025 CAN Transmit ID

 要如何可以同時傳送不同CAN ID and data,而且不用每次都要重新設定 CAN_setupMessageObject 。

每次重新設定 CAN_setupMessageObject 導致效率不太好,變成每個不同ID 傳送時間格都相差很大。

  • “同時傳送不同CAN ID and data”

    能否详细说明一下您具体需要实现的功能?
  • 我可能會透過CAN 通訊來知道ADC讀值之後,再透過CAN來傳上PC來讓我知道讀的值是多少正不正確。
    但我不一定只會看一筆資料,如果ADC 有 12 channel ,我可能需要最多可以同時監看12筆的CAN 訊號來得知訊息。
    但我現在如果透過 CAN_setupMessageObject 功能來不斷變更 CAN ID 的話,會看到CAN的通訊有延遲的現象。
    我知道同時監控12筆資料是不可能的,最多我也要可以看4~5筆資料是可以即時應對的。
  • 您可以看一下CAN发送数据的函数。您可以设置一个循环让各个ID循环发送。

    而发送数据的话您可以设置一个变量,而后将ADC的结果赋值给这个变量

    //*****************************************************************************
    //
    //! Sends a Message Object
    //!
    //! \param base is the base address of the CAN controller.
    //! \param objID is the object number to configure (1-32).
    //! \param msgLen is the number of bytes of data in the message object (0-8)
    //! \param msgData is a pointer to the message object's data
    //!
    //! This function is used to transmit a message object and the message data,
    //! if applicable.
    //!
    //! \note The message object requested by the \e objID must first be setup
    //! using the CAN_setupMessageObject() function.
    //!
    //! \return None.
    //
    //*****************************************************************************
    extern void
    CAN_sendMessage(uint32_t base, uint32_t objID, uint16_t msgLen,
                    const uint16_t *msgData);