3

I have two MCP2515 stand-alone CAN controllers with SPI interface, two TJA1042 CAN transceivers and two Arduino Uno boards. As you may know TJA1042 have two operational modes:

  1. Sleep mode

  2. Normal mode.

If I want to change the mode of operation of one transceiver from sleep mode to normal mode(wake it up), I should send a wake up pattern waves from the other transceiver which is in normal mode. for example one of the wake up patterns is: 5.5 µS low, 5.5 µS high and again 5.5 µS low. Now I don't know how to send these patterns with Arduino because MCP2515 is SPI interface.

I use this library: MCP_CAN

1

Transmitting this "wake signal" does not "wake" the transceiver. What it's actually doing is the transceiver, when in "standby" mode, only allows through signals that have a dominant or recessive state that is longer than the filter time (5.5µs). Any transitions in the bus after a stable period of 5.5µs or more will get passed through.

The transceiver does not enter "normal" mode at that point. It is down to the CAN device to activate the transceiver through setting the STB pin LOW.

When pin RXD goes LOW to signal a wake-up request, a transition to Normal mode will not be triggered until STB is forced LOW.

Exactly what you send is of no consequence to the transceiver - only whether it has D and R states that are longer than 5.5µS. It's up to the CAN device to interpret them and know if it should wake up the transceiver and place it in NORMAL mode.

And the MCP2515 also doesn't care what it receives. When the WAKEIE bit is set it will cause the MCP2515 itself to wake from its sleep mode when anything is received - at which point it signals to the Arduino through its INT pin that it's woken up.

However your chosen library has no ability included in it to control the WAKEIE bit of MCP_CANINTF - only the TXxIF bits are supported. So you will have to expand the library to provide that facility.

The general idea of operation is:

  • The transceiver lets through a "slow" signal (like transmitting 0b00110011)
  • The MCP2515 receives "something"
  • INT pin goes LOW and the Arduino reacts to it
  • The Arduino drives STB LOW and reception can proceed normally.

Note that it is the Arduino that will be controlling STB, not the MCP2515.

  • Thanks for answering me. Actually I have some testcases that I should test each of them. In each of them the R or D duration is different, So it's easy for me to use digital write and delay functions of Arduino.Maybe it's a stupid question but, Can I use GPIO of MCP2515 for it? – mtp Oct 7 '18 at 6:41
  • There are two pins that can be controlled as outputs - and they are primarily designed to be IRQ pins to indicate the receive interrupts to the MCU. If you are using a shield with the transceiver already wired, then no you can't, since you can't control the TX and RX pins as GPIO. If it's not already wired and you're wiring it yourself, then why would you? Just wire it to the Arduino and don't use the MCP2515. – Majenko Oct 7 '18 at 12:17
  • Thank you for helping me.Sorry for asking a lot of questions! Yes it becomes easy if I didn't use MCP2515, But I also have problem with baud rate of transceiver. When I don't use MCP2515 to set baud rate of CAN transceiver, bus signals aren't sharp enough. I don't use a shield and my mean of using GPIO was to send pulses using RXnBF pin of MCP2515. Is it possible?@Majenko – mtp Oct 7 '18 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.