1 Reply Latest reply on Dec 16, 2013 3:15 AM by HeLi_263931

    Changing the Data Length of the CAN Mailbox during Run time


      <b>Is it possible to change the Data length field for the CAN maibox during the run time ?</b>


      Yes . By default the data length for each of the CAN mailbox is defined in the CAN configuration window . In case if you need to change data length field for each of the message you are sending you need to modify the CMD register of the CAN transmitter .


      The datalength is stored in the DLC field of the CMD register. The CAN TX CMD register contains 4 bits to store the DLC value. The bit 19:16 contains the DLC for each mailbox. Below is the code snippet to change this value 


      CAN_TX[Mailbox_No].txcmd.byte[2u] &= 0xF0; 


      CAN_TX[Mailbox_No].txcmd.byte[2u] |= No_of_Data_Bytes;


      Through the above register write it is possible to change the DLC field during run time .