thomasonw / ATmegaxxM1-C1

Arduino IDE support files for CAN enabled Atmel AVR chips: ATmega64M1, ATmega32M1, ...
GNU Lesser General Public License v2.1
30 stars 18 forks source link

Sleep Mode #7

Closed geraldjust closed 6 years ago

geraldjust commented 6 years ago

Hi! sorry to bug again. But ive been trying to get the 64m1 to work with the low power library from here: https://github.com/rocketscream/Low-Power from the datasheets it seems like the 328p and the 64m1 are very similar. But i know there are a phew changed compared to the 328p. does not have a timer2, it only has 4 sleep modes rather then 6. And there are a couple of registers that are different as it doesn't have a i2c bus. But it does have LIN controller, and CAN. My question if it would be easy to port the low power library for this Micro. As one of the few reasons why this uC is interesting is that it also has a good low power way to manage it.

thomasonw commented 6 years ago

It should not be a problem placing any of of the AVR CPUs into lower power state, including the ATmegaxxM1 / C1 CPUs.

Chapter 9 of the datasheet talks about the different power-reduction modes, what is impacted and how the CPU exits those modes. The lib you referenced appears to provide an API method for accessing the registers and placing different subsystems into a low-power mode. You could follow that example, or look to some of the ones in the Atmel documentation.

One needs to consider which subsystems are not needed, and also how to exit the lower-power states. I noted the lib above seems to utilize the watchdog timer. This is one way, but there are others as well.

Myself, I suspect it would be better to create a power.cpp module in your sketch and do any power-states changes there, matching it to the application needs. One could start with the lib if it fits the goals, or perhaps use portions of it as a guide on how to access the low-level registers.