Author Topic: Atmega64M1 sleep and CAN bus wake  (Read 890 times)

0 Members and 1 Guest are viewing this topic.

Offline ifrythingsTopic starter

  • Contributor
  • Posts: 37
  • Country: ca
Atmega64M1 sleep and CAN bus wake
« on: April 20, 2025, 04:31:08 pm »
I’m working on a remote start module for my truck and I’m at the point I need to get the thing to go into low power/sleep mode when the vehicle is off. This unit is completely CAN bus controlled and in the data sheet I’m not seeing anything about waking it up from CAN bus activity. Is the Atmega64M1 able to be woken up from CAN? I don’t need it to wake up on any particular message (the message I look for is transmitted every 100ms and the message is repeated 3 times) just need it to figure out how to wake it up.

I’m using the Arduino environment and don’t mind having to make my own functions. I’m just wondering if anyone has experience with this micro and sleeping/waking on CAN. Any help is appreciated.
 

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: de
Re: Atmega64M1 sleep and CAN bus wake
« Reply #1 on: April 20, 2025, 07:46:36 pm »
The wake-up functionality is not part of the CAN MAC (i.e. the part inside the MCU), but inside the CAN PHY (==transceiver). The transceiver must support "partial networking". This is the keyword to look for.

One example is the NXP TJA1145:
https://www.nxp.com/docs/en/data-sheet/TJA1145.pdf

or this one from Infineon:
https://www.infineon.com/cms/en/product/transceivers/automotive-transceiver/automotive-can-transceivers/tle9255wsk/

You will need an additional SPI for setting registers inside the transceiver in addition to the usual CAN_TX/CAN_RX.

Both transceivers are CAN-FD capable. The Atmega 64M1 isn't. A superior replacement would be the Microchip dsPIC33CK256MC506, which is vastly more powerful and has got full CAN-FD capabilities up to 8 MBit/s.
https://www.microchip.com/en-us/product/dspic33ck256mc506
 
The following users thanked this post: voltsandjolts

Offline neillnz

  • Contributor
  • Posts: 25
  • Country: nz
Re: Atmega64M1 sleep and CAN bus wake
« Reply #2 on: April 23, 2025, 09:30:07 am »
The lack of a wake-on-CAN feature is annoying.

Perhaps this could work:

1. Transceiver stays powered on and if it has power modes/options set it to Rx only which will be much less than when Tx is enabled.
2. Parallel the CANRX PC3 port with one of the external interrupts INT3:0, configured as an input of course
3. Configure the MCU to wake on a rising edge of the chosen external interrupt
NOTE: It must be one of the external interrupt pins not a pin change interrupt.

See section 6.4 of the datasheet where it says " an external level interrupt on INT3:0 can wake up the
MCU"

So you could put the micro in to powerdown mode and it will wake upon the external int which will also be CAN activity.  Of course it will take time to wake up and start executing code so you could miss the first or a few CAN frames so if that is a deal breaker then this scheme won't work.

The easiest way to set this up would be to write to the registers directly.

Modified for grammer.
« Last Edit: April 23, 2025, 09:34:17 am by neillnz »
 

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: de
Re: Atmega64M1 sleep and CAN bus wake
« Reply #3 on: April 24, 2025, 05:56:52 am »
so you could miss the first or a few CAN frames so if that is a deal breaker then this scheme won't work.

Missing a few frames means hardware retires and going into a bus error state. This should never happen and can cause other problems in the car. Don't do it, there are proper ways to implement this.
 

Offline neillnz

  • Contributor
  • Posts: 25
  • Country: nz
Re: Atmega64M1 sleep and CAN bus wake
« Reply #4 on: April 24, 2025, 09:16:35 am »
ifrythings, If your intention is put your device to sleep to save power and to use the detection of CAN activity to wake it up then there is no problem in implementing what I suggest. As you say the message you are looking out for occurs 3 times 100 ms apart.

You could use a transceiver such as the NCV7351 which has a "silent mode" in which case it receives but cannot transmit. In "silent mode" the NCV7351 has a typical current consumption of 2.3 mA.
https://www.onsemi.com/pdf/datasheet/ncv7351-d.pdf

With a transceiver such as the NCV7351(there are of course plenty to choose from) and with tx disabled your device will be a passive listener on the network.

Am I correct in assuming that you do not intend to transmit onto the vehicle CAN network? 
         
 

Offline ifrythingsTopic starter

  • Contributor
  • Posts: 37
  • Country: ca
Re: Atmega64M1 sleep and CAN bus wake
« Reply #5 on: April 28, 2025, 07:34:12 pm »
Finally had a chance to work on this, the transceiver I originally spec’d was a TJA1042 but I ordered the wrong one, got the one with Vio instead of Vsplit output. So I put on a TJA1050 which I didn’t catch right away that it only has standby mode and no wake up ability. Did some digging through the junk pile I found a AMIS-42665 that is pin compatible and has wake up.

I tried what neillnz recommended and hooked up the RX pin to int0 pin and it appears to be working, I got to do more testing as I forgot to put the transceiver into sleep mode also but my current consumption went from ~40mA to ~10-15mA so that’s a great improvement right there.

Thanks fchk about the info of partial networking, I’ve never heard of that and looks like it could be useful in future projects.
 
The following users thanked this post: neillnz

Offline neillnz

  • Contributor
  • Posts: 25
  • Country: nz
Re: Atmega64M1 sleep and CAN bus wake
« Reply #6 on: April 29, 2025, 01:09:46 am »
I had a look at the AMIS-42665 datasheet. The typical supply current in standby mode is only 10 uA, awesome!

Please let us know what the current goes down to with the transceiver in standby mode.  Your current consumption should then be mostly the quiescent current of the Voltage regulator / converter.




 

Offline ifrythingsTopic starter

  • Contributor
  • Posts: 37
  • Country: ca
Re: Atmega64M1 sleep and CAN bus wake
« Reply #7 on: May 01, 2025, 02:40:55 am »
Finally got some measurements, I’m at camp(work) for 2 weeks so I had to scrounge around to find a few things, got an burnt out LED bulb and robbed the 4.7ohm fusible resistor out of it, borrowed a meter from work (none of the meters they would let me borrow had a low mA range so I had to get the resistor for a current shunt) and did a few tests.

Running 34.9mA
Sleep with transceiver on 13.1mA
Sleep with transceiver off 8.57mA
Held in reset 6.3mA

I’m using a MC09XS3400 as my output driver and I tied what I thought was a general reset line to my reset circuit, I think this thing isn’t going to sleep when I set the wake pin to zero as the RSTB pin should also be low with the wake pin. According to the data sheet the MC09XS3400 will draw 6.5mA - 7.5mA in standby, should draw 1uA-5uA in sleep mode.

Unfortunately I don’t think I can do anymore testing till I’m home and can start removing parts and fix my errors and see if what I think is causing the problem really is the problem.

Edit: luckily I followed the datasheet’s recommended circuit and put 10k resistors on all the signal pins, just put the board into sleep mode and grounded the RSTB pin and the current went from 8.57mA to 551uA, just another small bodge wire and this thing will be running soon.
« Last Edit: May 01, 2025, 03:42:25 am by ifrythings »
 
The following users thanked this post: neillnz

Offline neillnz

  • Contributor
  • Posts: 25
  • Country: nz
Re: Atmega64M1 sleep and CAN bus wake
« Reply #8 on: May 02, 2025, 06:50:44 am »
Finally got some measurements, I’m at camp(work) for 2 weeks so I had to scrounge around to find a few things, got an burnt out LED bulb and robbed the 4.7ohm fusible resistor out of it, borrowed a meter from work (none of the meters they would let me borrow had a low mA range so I had to get the resistor for a current shunt) and did a few tests.

Running 34.9mA
Sleep with transceiver on 13.1mA
Sleep with transceiver off 8.57mA
Held in reset 6.3mA

I’m using a MC09XS3400 as my output driver and I tied what I thought was a general reset line to my reset circuit, I think this thing isn’t going to sleep when I set the wake pin to zero as the RSTB pin should also be low with the wake pin. According to the data sheet the MC09XS3400 will draw 6.5mA - 7.5mA in standby, should draw 1uA-5uA in sleep mode.

Unfortunately I don’t think I can do anymore testing till I’m home and can start removing parts and fix my errors and see if what I think is causing the problem really is the problem.

Edit: luckily I followed the datasheet’s recommended circuit and put 10k resistors on all the signal pins, just put the board into sleep mode and grounded the RSTB pin and the current went from 8.57mA to 551uA, just another small bodge wire and this thing will be running soon.

Using the fusible resistor from the dead LED lamp is genius, or is that MacGyver like.
 

Offline ifrythingsTopic starter

  • Contributor
  • Posts: 37
  • Country: ca
Re: Atmega64M1 sleep and CAN bus wake
« Reply #9 on: May 02, 2025, 12:30:49 pm »
A few weeks ago we had an LED bulb doing the disco flashing, I pulled the bulb and as usual I’m always curious what’s in these things and pulled it apart, noticed they used a 4.7ohm 1/2w flame proof resistor for the input “fuse”. The meter that I was allowed to borrow was a Fluke 117 which doesn’t have the low mA range but would read to the 1/10 of a mV, that’s when I went to find another dead LED and rob the resistor. I’m going to redo this test at home with a 10ohm resistor and the fix done and see what it really sleeps at as I think it will be half as much of the 551uA when I’m not grounding a 10k resistor off my 5v reset line.
« Last Edit: May 02, 2025, 12:33:30 pm by ifrythings »
 
The following users thanked this post: neillnz

Offline ifrythingsTopic starter

  • Contributor
  • Posts: 37
  • Country: ca
Re: Atmega64M1 sleep and CAN bus wake
« Reply #10 on: Today at 02:30:51 am »
Final bench testing sleep current is just a hair under 300uA! I didn’t have a set goal for what I wanted the sleep current draw to be but I was hoping less than 5mA, this is way past my expectation and I’m very happy with 300uA. Put the remote start in my brothers truck to give it the run down (and the first try with the actual vehicle CAN bus) and everything is working like it should, it even goes to sleep when all the other modules send the network sleep request. I didn’t have a chance to see if it misses the first sent frame after wake up or not.
 
The following users thanked this post: neillnz


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf