Skip to content

Commit

Permalink
Clarify MCP2515 pumpEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
solomondg committed Jan 10, 2025
1 parent ca5cfff commit 2725da4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions examples/SineWaveCAN/SineWaveCAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ void setup() {

void loop() {
pumpEvents(can_intf); // This is required on some platforms to handle incoming feedback CAN messages
// Note that on MCP2515-based platforms, this will delay for a fixed 10ms.
// This has been found to reduce the number of dropped messages, however it can be removed
// for applications requiring loop times over 100Hz.

float SINE_PERIOD = 2.0f; // Period of the position command sine wave in seconds

Expand Down
9 changes: 6 additions & 3 deletions src/ODriveMCPCAN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ static void onReceive(const CanMsg& msg, ODriveCAN& odrive) {
}

static void pumpEvents(MCP2515Class& intf) {
// nothing to do
// TODO: maybe remove
delay(10); // not sure why this resulted in less dropped messages, could have been a twisted coincidence
// On other platforms, this polls and processes incoming CAN messages.
// However, this is not possible on MCP2515-based platforms.

// A 10ms delay was found to reduce the number of dropped messages, however a
// specific root cause has not been identified, and may be a quirk in the MCP2515.
delay(10);
}

CREATE_CAN_INTF_WRAPPER(MCP2515Class)

0 comments on commit 2725da4

Please sign in to comment.