This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CAN driver question ...

Hi,

I am using the RL-ARM provided CAN driver. I have the need to configure receive messages after I started the CAN driver. I use "CAN_rx_object" to configure new receive objects (CAN-controller 2) and this part is working. I noticed that after using "CAN_rx_object" in a running CAN system, the CAN-controller 1 is impacted and generates errors. I have a CANOpen driver handling the traffic on the CAN-controller 1.

Here are my questions:

- Can I use "CAN_rx_object" after I started the CAN controller (the documentation does not provide further information)?

- Why is CAN-controller 1 impacted if CAN-controller 2 is reconfigured?

Thank you - Frank!

Parents
  • Hi,

    I suggest you try to call function CAN_hw_init before calling CAN_rx_object and then call start function after it so something like this:

    CAN_hw_init (1, 100000);
    CAN_hw_init (2, 100000);
    CAN_rx_object(2, 0, 22, STANDARD_FORMAT);
    CAN_start (1);
    CAN_start (2);

Reply
  • Hi,

    I suggest you try to call function CAN_hw_init before calling CAN_rx_object and then call start function after it so something like this:

    CAN_hw_init (1, 100000);
    CAN_hw_init (2, 100000);
    CAN_rx_object(2, 0, 22, STANDARD_FORMAT);
    CAN_start (1);
    CAN_start (2);

Children
  • Hi,

    I identified the problem. In the function "CAN_hw_rx_object" the following changes are necessary:

      /* Setup Acceptance Filter
         Configuration
         Acceptance Filter Mode Register = OFF */
      u32 afmr = ptrcan_af->AFMR;
      ptrcan_af->AFMR = 0x00000001;
    
      ...
    
      ptrcan_af->AFMR = afmr;
    

    With these changes the CAN-Ctrl1 and CAN-Ctrl2 don't interfere each other in case of new acceptance filter settings.

    - Frank

  • What you have done is really not quite ok, as what you have done is you have turned Acceptance filtering off, because you store to variable afmr values of Acceptance filter mode register which has value 2 after init function (meaning it is turned off).
    And at the end of the function you return that value 2 thus leaving Acceptance filter turned off.

  • Hi Milorad,

    it is the only feasable solution as far as I can tell. The datasheet specifies only one bit to enable hardware identifier filtering. This means that both controllers have to use this feature or both have to use software filtering. In my case I have to use both controllers without acceptance filter.

    - Frank

  • If you need filtering on one channel, then you should be able to set up a wild-card filter for the other channel, and run with the AF turned on.

  • Hi Frank,

    if you do not need to use Acceptance filter then it is a better solution that you do not call functions CAN_rx_object as that function switches acceptance filter to be used.
    Function CAN_init initializes acceptance filter as not used.

    There is no point in calling CAN_rx_object function if you are not using hardware filtering (acceptance filter).

    Milorad