I am trying to get started with a CAN bus project and noticed that it’s not supported on Argon?
Copying the example seem compiles fine with a Photon but fails with Argon:
‘CAN_D1_D2’ was not declared in this scope
Can it be that CAN does not work with argon?
Code is:
// EXAMPLE USAGE on pins D1 & D2
CANChannel can(CAN_D1_D2);
void setup() {
can.begin(125000); // pick the baud rate for your network
// accept one message. If no filter added by user then accept all messages
can.addFilter(0x100, 0x7FF);
}
void loop() {
CANMessage message;
message.id = 0x100;
can.transmit(message);
delay(10);
if(can.receive(message)) {
// message received
}
}
The STM32 controller on Photons has a HW CAN interface which the nRF52840 on the Argon hasn’t, so the code shouldn’t build.
You’ll also not find the CAN object in the reference docs for Mesh devices.
1 Like
Thanks a bunch.
I did notice this later. Any idea if one could software bit-bang a CAN bus ?
AFAICT timing would be one of the most fundamental hurdles as there currently is only one free HW timer and no library for high level access to facilitate it in user code.
I don’t know of anybody who has taken that on yet.
As soon as Particle can free more HW timers I’d suspect @peekay123 would be the first to jump on to add Gen3 support for his SparkIntervalLibrary
which is a key element of many time critical libraries.
But we don’t have any idea about ETA for that.
1 Like
A better approach would be to use CAN BUS interface controller like the MCP2515. There are boards and libraries available for it.
1 Like