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

RL-CAN library and receive mask

Hello everyone,

Question

I want my CAN to receive every message with ID 0x1000 to 0x1FFF, how can I do it ?

Ugly solution

NB: My CAN(s) can already receive messages with CAN_receive() by calling CAN_rx_object() with the correct ID.

U32 i = 0;

for (i = 0x1000; i < 0x1FFF; i++)
{
  CAN_rx_object(CAN_CTRL, CAN_CH, i, DATA_TYPE | EXTENDED_TYPE);
}
/* ... */

Is there something more elegant to do so ?

Best regards,

Vincent

--
Apendix
Device: LM3Sxxxx (LM3S9B96)
CAN : Basic CAN

  • As CAN is provided at source level you can easily extend functionality to be able to use mask instead of single IDs.

  • I've checked documents of RL-CAN and found it a rather 'general & simple' implementation.

    I think it's mainly for quickly launching and slight use. Not for uC-specific and highly customized CAN application.

  • Why, what do you think is missing?

    We are not talking about higher level protocols built on CAN like DeviceNET or similar?

  • To begin, thanks a lot for your replies !
    It helped me a lot to find the solution.

    Are you sure that, the CAN controller of LM3S9B96 is Basic CAN?
    


    You are right, LM3S9B96 is a Full CAN with receive FIFO.

    You should be able to configure one message object to only
    receive ID 0x1000 to 0x1FFF. However, it seems RL-CAN can not
    do this for you.
    


    I had to go under RL-CAN, precisely in the file CAN_LM3Sxxxx.c, function:

    CAN_ERROR CAN_hw_rx_object (U32 ctrl, U32 ch, U32 id, U32 object_para)
    
    As CAN is provided at source level you can easily extend
    functionality to be able to use mask instead of single IDs.
    


    For this kind of device family, it was mainly about setting mask value.
    Imagine mask as a 29 bit value where a '1' means keep the value and '0' is "I don't care".
    exemple
    I want my CAN to receive every message with ID 0x1000 to 0x1FFF

    U32 msk = 0x00001000
    
    

    Best regards,

    Vincent

  • Hi Vincent, we've faced the same problem. We need to be able to receive up to 40 different CAN msgs. What is the solution you had found?

    We use STM32F103.


  • --> Device: LM3Sxxxx (LM3S9B96)
    -> We use STM32F103.

    Actually, you are talking about a completely different MCU, and a completely different CAN Controller.


    22 Controller area network (bxCAN)
    Low-density devicesare STM32F101xx, STM32F102xx and STM32F103xx
    microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.

    22.2 bxCAN main features
    Transmission: Three transmit mailboxes, Configurable transmit priority, Time Stamp on SOF transmission
    Reception: Two receive FIFOs with three stages, Scalable filter banks: