-
Notifications
You must be signed in to change notification settings - Fork 29
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
Esp32TWAI driver churns on interrupts when there is no CAN plugged in #739
Comments
@atanisoft fyi |
Let me see what I can find, I agree this is a sub-optimal behavior. I'm not seeing anything specific in the ESP-IDF driver that would handle this differently. |
Maybe the answer would be that the error interrupt should be masked.
…--
Sent from my mobile device
|
Perhaps, but there may be other conditions masked by doing that. Perhaps the WD task could disable/enable the interrupt when it wakes every ~10sec if the TX/RX count has changed since last wake up? |
check the datasheet, maybe there is a way to mask only the error interrupt
(without masking the rest of the interrupts). Usually hardware peripherals
have an interrupt mask register themselves that determines what interrupt
sources are enabled. Those sources are then OR-ed together to drive the
interrupt line to the core.
|
from the S3 datasheet, it looks like the bus-error interrupt flag can be isolated but there are some usages of this bit in ESP-IDF (ref). It also appears that |
It may also make sense to implement handlers for the following events which are currently ignored:
These are currently being set by the HAL layer but not used. |
I've dug through the TWAI code and this bus-error count increasing is occurring AFTER the driver enters error-passive state. It also does not ever appear to transition to the bus-off state after entering error-passive state. Making it worse though is the entire SimpleCanStack can enter a 100% blocked state due to the traffic failing during TX (silently failing due to error-passive). I've pushed this commit to my 5.1.0 branch and have yet to encounter an issue. I'll be raising it as a PR here soon. |
Here is an example output from the TWAI report messages with no CAN-bus plugged in:
each "err" counter is one interrupt (event) with
This means that we are getting about 15k interrupts in five seconds when there is no CAN-bus plugged in. That's an unexpectedly high churn for something that's a pretty common condition.
The expected behavior is that the device goes into bus-off and sends an interrupt next time there is a valid received frame or the frame happens to be transmitted correctly.
The text was updated successfully, but these errors were encountered: