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

STM32H7 Can Filter & Can bus-off State Handling #21701

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

henrykotze
Copy link

Exception handling for bus-off state in the STM32H7 driver, and first go at implementing the CAN filters

Based on the following STM32 Documents:
RM0433 - Reference manual for STM32H742, STM32H743/753 and STM32H750 Value line
AN5348 - Introduction to FDCAN peripherals for STM32 product classes
TN1367 - Bus off management in MCAN controllers

Context

  • Our ESCs on powerup, causes the CAN bus to go into bus-off state. Currently their is no handling of this state in the STM32H7 driver, and results in the FMU to be 'kicked' off from the Canbus.

Implementation

  • Added the can bus off state into the interrupt register, and handling this state. Currently in both interrupts, there is a check for whether this interrupt has been triggered, but it might only be necessary on one of them.
  • Added Can filters, unsure whether they work as intended (I dont think they do), would be great if someone with more experience have a look at this.

Copy link
Member

@davids5 davids5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline

@henrykotze
Copy link
Author

Standard Filter Register

image
image

Extended Filter Register

image
image

Would be great if someone could have a peek if the way how I implement the filter are correct, because I am not too sure if they are working as intended.

@henrykotze
Copy link
Author

@davids5 anything else here to do, except for squash comments?

I can confirm the bus is much more stable. We can short the CANH and CANL, and it will recover perfectly. The only thing I am unsure about is the filter implementation. @JacobCrabill do you have comments or suggestion to make? I just @ you due to your work on the initial driver work :)

Copy link
Member

@davids5 davids5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henrykotze LGTM but please squash/Fix it up the commits

@junwoo091400 junwoo091400 changed the title [WIP] STM32H7 Can Filter & Can bus-off State Handling STM32H7 Can Filter & Can bus-off State Handling Jul 12, 2023
@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/px4-community-q-a-july-12-2023/33086/4

@dagar dagar merged commit f82785a into PX4:main Jul 12, 2023
@henrykotze henrykotze deleted the wip-can-filters-stm32-h7 branch July 13, 2023 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants