Can't use CAN2 without CAN1, and filters

Report here problems in any of ChibiOS components. This forum is NOT for support.
steved
Posts: 531
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 3 times
Been thanked: 54 times

Can't use CAN2 without CAN1, and filters

Postby steved » Fri Nov 24, 2017 11:00 am

Using 32F767, but probably applies to all.

1. The hardware allows use of CAN2 without CAN1 being active; while there are interactions, these appear to be solely or largely in the area of filters. (See 40.9.4 in RM0410 makes it clear that this is a supported configuration). However the current driver requires CAN1 to be started, even if not used, before CAN2 can be started.

2. canSTM32SetFilters(), which I assume to be the 'official' API for setting of the filters clearly expects to be called before the driver is started. However it is possible to update the filters at run-time by setting FINIT in CAN_FMR register. (I've got other comments on the API to the filters, but since they're by way of enhancements, I'll post them elsewhere)

User avatar
Giovanni
Site Admin
Posts: 11080
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 367 times
Been thanked: 306 times
Contact:

Re: Can't use CAN2 without CAN1, and filters

Postby Giovanni » Fri Nov 24, 2017 11:12 am

hi,

Could you post a patch for this?

Giovanni

steved
Posts: 531
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 3 times
Been thanked: 54 times

Re: Can't use CAN2 without CAN1, and filters

Postby steved » Fri Nov 24, 2017 1:07 pm

Giovanni wrote:Could you post a patch for this?

Eventually - not expecting to have hardware to play with and test for a week or two. And it'll include some extensions to the API to support filter updates on the fly. (Code's pretty much done; just needs testing/debugging, so can make available if anyone else has this problem)

User avatar
Giovanni
Site Admin
Posts: 11080
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 367 times
Been thanked: 306 times
Contact:

Re: Can't use CAN2 without CAN1, and filters

Postby Giovanni » Sat Jan 20, 2018 4:35 pm

Bump, is this still a thing?

Giovanni

steved
Posts: 531
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 3 times
Been thanked: 54 times

Re: Can't use CAN2 without CAN1, and filters

Postby steved » Sun Jan 21, 2018 10:16 am

Giovanni wrote:Bump, is this still a thing?

Giovanni

Yes it is - working on CAN ATM, but not to the point of having anything to submit yet.

hercek
Posts: 13
Joined: Wed Sep 20, 2017 9:33 pm
Been thanked: 2 times

Re: Can't use CAN2 without CAN1, and filters

Postby hercek » Sun Jan 21, 2018 5:49 pm

CAN1 must be started before CAN2 (even when only CAN2 is used) on STM32F405 too.

User avatar
Giovanni
Site Admin
Posts: 11080
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 367 times
Been thanked: 306 times
Contact:

Re: Can't use CAN2 without CAN1, and filters

Postby Giovanni » Fri Jul 27, 2018 2:57 pm

bump

hercek
Posts: 13
Joined: Wed Sep 20, 2017 9:33 pm
Been thanked: 2 times

Re: Can't use CAN2 without CAN1, and filters

Postby hercek » Thu Aug 02, 2018 5:19 pm

It is not fixed in stable_18.2.x.
See ChibiOS/os/hal/ports/STM32/LLD/CANv1/hal_can_lld.c

Code: Select all

689     #if STM32_CAN_USE_CAN2
690       if (&CAND2 == canp) {
691
692         osalDbgAssert(CAND1.state != CAN_STOP, "CAN1 must be started");
693
694         rccEnableCAN2(true);
695       }
696     #endif

steved
Posts: 531
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 3 times
Been thanked: 54 times

Re: Can't use CAN2 without CAN1, and filters

Postby steved » Thu Aug 02, 2018 9:33 pm

It looks pretty definite that if CAN2 is enabled, CAN1 has to be also enabled within the HAL. Possibly this can be done automatically in the LLD.

Should have some proposed updates to the LLD eventually - one point being considered is where one draws the line between the standard LLD and optional 'helper' functions. These helpers are very ST-specific, so logically would go with the ST-specific driver. But its debateable whether they should be in the single LLD file, or in a separate file. Any thoughts?

User avatar
Giovanni
Site Admin
Posts: 11080
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 367 times
Been thanked: 306 times
Contact:

Re: Can't use CAN2 without CAN1, and filters

Postby Giovanni » Thu Aug 02, 2018 9:39 pm

The assertion is correct even if less than optimal.

Probably it should be automatic like steved suggested, it should not be hard to do. Enable clock in canStart(), disable clock in canStop() if both instances are stopped, one "if".

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest