Hardware CAN Acceptance Filter Works !!!!!

20 Mar 2011

Hello, (Polytech Paris Sud Orsay) We resolved CAN Acceptance Filter problem. We know now how it Works.

our problem is to attach interrupt to CAN class to manage received Frames without explicit call to read in the main program.

The Attach method don't work because the ISR dont Activate IDIE bit and dont test IDI bit of the ICR register.

Just call init_AF function before entering While(1) loop.

/ Begin program /

void init_AF( void )

int32_t address = 4;

/*off mode*/

LPC_CANAF->AFMR = 0x00000001;

/* Set explicit standard Frame*/

LPC_CANAF->SFF_sa = address;/* word 1*/

/* CAN2 IDENT FORCE1*/

LPC_CANAF_RAM->mask[1]=(0X001 << 29) | (0X400 << 16)| (1<<27)|

(0X001 << 13)| (0X500 ) | (1<<11) ;

/* Only Frame ID 0x400 and 0x500 are received in MBED.*/

address+=4;/*add 4 bytes (1 long word) to point to none used word.*/

/* Set group standard Frame*/

LPC_CANAF->SFF_GRP_sa = address;

/* Set explicit extended Frame*/

LPC_CANAF->EFF_sa = address;

/* Set group extended Frame*/

LPC_CANAF->EFF_GRP_sa = address;

/* Set End of Table */

LPC_CANAF->ENDofTable = address;

/* All have ENDofTable address means are not used.*/

/*normal mode*/

LPC_CANAF->AFMR = 0x00000000;

return;

/* end Program */

Now continue to add attach_Acceptance_Filter method to add ISR.

Good experience.

I will post CAN_ACC_FILTER program example.

20 May 2011

Hi Samir,

can you post the program example?

I cannot get my own running. Interrupt driven CAN reception with acceptance filter disabled works great!

When I enable the acceptance filter, no more messages are received! I filter for 0x12f and 0x130 on CAN2 by setting LPC_CANAF_RAM->mask[1]=0x492F4930 or LPC_CANAF_RAM->mask[1]=(0X001 << 29) | (0X12F << 16)| (1<<27)| (0X001 << 13)| (0X130 ) | (1<<11)!

Btw I found out that also setting the AccBP doesn't work.

[..]

LPC_CANAF->AFMR = 0x00000010;

printf("AFMR register: 0x%x\r\n", LPC_CANAF->AFMR);

[..]

The terminal always shows 'AFMR register: 0x0x00000000'

Could you give me a hint what is going wrong here!?

Thanks a lot!

Best wishes

06 Jun 2011

It's really an hard work! Can you show us your soft ?

Really thank's

Rom

20 Sep 2011

Following is a copy of my post.

http://mbed.org/forum/helloworld/topic/784/?page=1#comment-13843

Quote:

Found CAN_wrFilter() function at following site.

http://www.dragonwake.com/download/LPC1768/Example/CAN/CAN.c

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

FYI,

I published a sample program of the CAN filtering.

http://mbed.org/users/ym1784/programs/CAN_MONITOR/m77jas

18 Dec 2012

Following is a copy of my post.

http://mbed.org/forum/helloworld/topic/784/?page=1#comment-20837

Yoshi Mimura wrote:

link update

Yoshi Mimura wrote:

Found CAN_wrFilter() function at following site.

http://www.dragonwake.com/download/LPC1768/Example/CAN/CAN.c

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

http://www.dragonwake.com/download/LPC1768/Example.zip

11 Jul 2016

I confirm that Yoshi Mimura's https://developer.mbed.org/users/ym1784/code/CAN_MONITOR/file/fe1f886dff76/main.cpp CAN filter works well.

Thank you, Yoshi! You saved me immense amount of time!