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

Fix: Determine if CAN TX is ongoing by reading from the TXBnCTRL register. #55

Merged
merged 1 commit into from
Jan 31, 2022

Conversation

aentinger
Copy link
Member

Possible alternate solution for #54, without busy waiting.

@pepeRossRobotics can you please test? 🙏

@aentinger aentinger added type: enhancement PR to improve the project. topic: firmware Code that runs on an embedded system. labels Jan 30, 2022
@aentinger aentinger self-assigned this Jan 30, 2022
@github-actions
Copy link

Memory usage change @ f66a9ec

Board flash % RAM for global variables %
arduino:mbed_edge:edge_control 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m4 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 🔺 0 - +64 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrfox1200 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 🔺 0 - +36 0.0 - +0.01 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 0 - +40 0.0 - 0.0 0 - 0 0.0 - 0.0
rp2040:rp2040:rpipico 🔺 0 - +32 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/MCP2515-CAN-Sniffer
flash
% examples/MCP2515-CAN-Sniffer
RAM for global variables
% examples/MCP2515-Loopback
flash
% examples/MCP2515-Loopback
RAM for global variables
%
arduino:mbed_edge:edge_control 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nano:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nano:nanorp2040connect 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_portenta:envie_m4 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_portenta:envie_m7 0 0.0 0 0.0 64 0.01 0 0.0
arduino:samd:mkr1000 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrfox1200 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrgsm1400 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrnb1500 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrvidor4000 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrwan1300 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrwan1310 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrwifi1010 0 0.0 0 0.0 36 0.01 0 0.0
arduino:samd:mkrzero 0 0.0 0 0.0 36 0.01 0 0.0
esp32:esp32:esp32 0 0.0 0 0.0 40 0.0 0 0.0
rp2040:rp2040:rpipico 0 0.0 0 0.0 32 0.0 0 0.0
Click for full report CSV
Board,examples/MCP2515-CAN-Sniffer<br>flash,%,examples/MCP2515-CAN-Sniffer<br>RAM for global variables,%,examples/MCP2515-Loopback<br>flash,%,examples/MCP2515-Loopback<br>RAM for global variables,%
arduino:mbed_edge:edge_control,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m4,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,64,0.01,0,0.0
arduino:samd:mkr1000,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrfox1200,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrgsm1400,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrnb1500,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrvidor4000,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrwan1300,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrwan1310,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrwifi1010,0,0.0,0,0.0,36,0.01,0,0.0
arduino:samd:mkrzero,0,0.0,0,0.0,36,0.01,0,0.0
esp32:esp32:esp32,0,0.0,0,0.0,40,0.0,0,0.0
rp2040:rp2040:rpipico,0,0.0,0,0.0,32,0.0,0,0.0

@pepeRossRobotics
Copy link

pepeRossRobotics commented Jan 31, 2022

This is with my home brew wait:
image

This is with this commit's code:
image

As you can see the amount of errors is around double (the up-time of both nodes was around 7 minutes), but the the modification of the performance of the code is orders of magnitude better than the master branch in that regard.

I think this fix performs very similar, but it is more elegant and efficient than my version, so happy to use it instead of mine.

What do you think?

@aentinger aentinger marked this pull request as ready for review January 31, 2022 09:06
@aentinger
Copy link
Member Author

Thank you very much for the test. I'd prefer this variant to your PR, since it does not contain any busy-wait. If this is fine with you I'll merge this and close the other. As for the remaining errors ... possibly the CAN timings are too tight leading to frame errors due to out-of-margin bit-timings? Possibly also the SPI clock is too high for the MCP2515 resulting in bit errors during transmission? Those timing issues are hard to pin down ...

@pepeRossRobotics
Copy link

Agree with you. Thanks for taking the time to check this and come up with a better solution.

@aentinger aentinger merged commit 57e8ae8 into master Jan 31, 2022
@aentinger aentinger deleted the fix-frame-error branch January 31, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: firmware Code that runs on an embedded system. type: enhancement PR to improve the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants