Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embot::hw::can -> fixed ID filters for the FDCAN case #287

Merged
merged 1 commit into from
Aug 10, 2022
Merged

embot::hw::can -> fixed ID filters for the FDCAN case #287

merged 1 commit into from
Aug 10, 2022

Conversation

marcoaccame
Copy link
Contributor

@marcoaccame marcoaccame commented Aug 9, 2022

This PR fixes the CAN ID filtering for the case of FDCAN peripherals and affects boards such as pmc, amcbldc and amc.

Before this change, for the above boards the ID filtering was not effective and the boards received every CAN frame, the so called pass-all behavior. Now, the HW filters of the FDCAN peripheral select the CAN frames by their IDs.

The selection allows only messages for:

  • bootloader class sent to the board or in broadcast;
  • analog sensor command class sent to the board or in broadcast;
  • motion control command class sent to the board or in broadcast;
  • motion control streaming class sent by address 0.

In this way the CPU of each board processes only what it needs.

The previous pass-all behavior is not wrong per se, but in some cases of excessive traffic it caused reception problems which prevent the drive to work correctly.

It is the case of the new wrist in iCub, where we have three amcbldc boards. In here if we don't use filtering, each board receives almost in at the same time up to 5 CAN frames, when only one is relevant to the board.

Problem is that the RX FIFO0 buffer which is used to accumulate the frames before the IRQ Handler can get them can host only three messages.

In this PR I fixed the above case by:

  • activating the global filtering,
  • applying the correct filtering for the CAN protocol messages relevant to each board,
  • improving the RX callback activate by teh IRQ Handler to consider the cases of FDCAN_IT_RX_FIFO0_MESSAGE_LOST and FDCAN_IT_RX_FIFO0_FULL,
  • increasing the number of allowed filters in the FDCAN driver.

The changes were tested on a pmc board for what is related to correct ID filtering and on a strain2 board to verify that there are no side effects on older boards and finally on the amcbldc boards of the wrist.

NOTE: the amc board must be able to receive every frame and this behavior is satisfied. That happens because it calls only embot::hw::can::init() which by default enables the pass-all mechanism. The filter is activated only by embot::hw::can::setfilters() which the amc must not call.

@marcoaccame marcoaccame self-assigned this Aug 9, 2022
@marcoaccame marcoaccame marked this pull request as draft August 9, 2022 15:48
@marcoaccame marcoaccame marked this pull request as ready for review August 10, 2022 09:05
@marcoaccame marcoaccame merged commit e19620e into robotology:devel Aug 10, 2022
@marcoaccame marcoaccame deleted the fix/embot-hw-can-filters branch October 13, 2022 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant