Filter out a CAN-message with an unique frame-id

31 May 2010

How do I filter out a CAN-message with an unique frame-id ?

On a car-CAN-bus I only want to see CAN-message with, lets say, the address x01E5.

I have seen in the manual for LPC1768 that it has acceptance filters for the CAN-controller.


01 Jun 2010

I think, you have to program the acceptance filter yourself. Thats how i did it, because i didn't find a function for that in the mbed library.

01 Jun 2010

Hello Sebastian,

Sounds great !  How did you do it?

Grateful if you can show me.


02 Jun 2010 . Edited: 02 Jun 2010

This ist for using 29 Bit ID. If you want to use 11 Bit ID it would be a little bit different, but I can write it here as well, if you want. (I'm sorry for my englisch)

// 1x 29 Bit ID -> END_OF_TABLE = 4; SCC 1; 

void CanWrFilter(unsigned char SCC, unsigned int ID){

unsigned int                 value;

LPC_CANAF->AFMR = 0x00000001;  // Setup Acceptance Filter Configuration; Acceptance Filter Mode Register = Off;

value =  ((SCC-1)<<29) | id ;
LPC_CANAF_RAM->mask[0]= value;

/* Setup acceptance filter pointers */

LPC_CANAF->SFF_sa     = 0;
LPC_CANAF->EFF_sa     = 0;

LPC_CANAF->AFMR = 0x00000000;                  // Use acceptance filter


02 Jun 2010

Just so that you know, CAN has not been forgotten, and is in my work queue to look at quite soon.

14 Feb 2011

Jon any news of adding filters soon?

14 Feb 2011

Hi Jason,

We don't plan to have filters added to the core libraries at the moment. This is partly as controllers seem to do it in different ways, so there wasn't immediately an obvious way to abstract this, but also to see how people start to use CAN and how we can best support it. There are lots of higher level CAN stacks, so I'm assuming people will start porting and using them for more complex projects. The focus of the libraries at the moment is not to support every eventuality, but the core functionality that gets something up and running.

I'd encourage you to poke the appropriate registers to setup the filters as Sebastian demonstrates, and if you do find a natural way, perhaps wrap it up in a small library so others can experiment. Would be great to see if a useful model emerges.

Hope your project is going well :)


04 Mar 2011

Hi everybody!

I don't understand what is LPC_CANAF and LPC_CANAF_RAM in Sebastian's code.

Thank you for your reply

20 Sep 2011

Found CAN_wrFilter() function at following site.

It works great as expected.

  setup acceptance filter.  CAN controller (1..2)
void CAN_wrFilter (uint32_t ctrl, uint32_t id, uint8_t format);
26 Mar 2012


I published a sample program of the CAN filtering.

18 Dec 2012

link update

Yoshi Mimura wrote:

Found CAN_wrFilter() function at following site.

The CAN.c file has been removed from the site. Instead, the whole file is placed as follows;

26 Oct 2016


I need help on a task that requires me to extract a key from the CAN bus KoIEIkCAAACnAAAAIE4AAAAAAAAAAAAA////////9wMAAAACQB There is no need to interpret it but I just need to extract this from the CAN bus. the Identifier is 11bit and the Data is 60 byte in all coming from the multiplexers. Could you help me with the software, hardware and code to extract this.

kindly help thanks

Thank you for entering into the world of new dimensions. I am delighted to join the conversation.[url=][color=#ffffff]gclub[/color/][/url]

14 Sep 2019

Are CAN filters now added to the library ?