Page 1 of 1

PCAN-Router not running new code

Posted: Wed 21. Sep 2011, 12:49
by murpia
Hi,

We wish to use a PCAN-Router to translate 1Mbps CAN to 500kbps CAN, with message filtering, to produce a 'gateway'.

Following all instructions in the manual I am able to build new software with the new bit rates and message filtering in software.

Is example code available for using the hardware message filtering of the PCAN-Router?

Thanks, Ian

Re: PCAN-Router not running new code

Posted: Wed 21. Sep 2011, 14:01
by P.Steil
Hello Ian,

in can_init.c ( near line 91) you can find code like:

CAN_InitFilters();
CAN_SetFilterMode ( AF_ON_BYPASS_ON);


This code will disable (bypass) the filter. To get hardware filtering for CAN-IDs you can use
code like this:


CAN_InitFilters();

// filter ID 0x500 explicit
CAN_FilterAddId ( CHANNEL_0, FILTER_11BIT_ID, 0x500);

// filter ID 0x600 - 0x605 as range
CAN_FilterAddId ( CHANNEL_0, FILTER_11BIT_ID_RANGE, 0x600, 0x605);

// filter ID 0x4875 explicit
CAN_FilterAddId ( CHANNEL_1, FILTER_29BIT_ID, 0x4875);

// activate Filter
CAN_SetFilterMode ( AF_ON);



Regards
Philipp Steil

Re: PCAN-Router not running new code

Posted: Fri 13. Mar 2015, 20:56
by shufenghan
What is the maximum number of CAN ids that can be added in harware filtering (CAN_FilterAddId( ))?

Thanks
Shufeng

Re: PCAN-Router not running new code

Posted: Mon 16. Mar 2015, 14:44
by P.Steil
Hello,

you can add a maximum of 2048 bytes of Filter Tables. The sizes are as follows:

- standard single -> 2 byte
- standard range -> 4 byte
- extended single -> 4 byte
- extended range -> 8 byte

Regards
Philipp Steil