I am designing a low-power RF application using an ATTiny (Adafruit Trinket).
When the system receives a radio signal, it needs to read some sensors, and transmit with that data. Because I am short on pins, I am trying to think of creative (low-pin count) ways to design this system.
My current idea is:
- Put the AVR to sleep.
- Connect the radio's Rx Interrupt pin to the AVR Reset pin
- When the AVR is reset, check the radio buffer
- (if there's nothing in the buffer, assume this is a real power-on reset and go back to sleep)
- Otherwise, read sensors, transmit
- Go back to sleep
My aim here is that the AVR will use very little power while sleeping (furthermore, it will only need to wake up a few times per day).
Is it reasonable to use the AVR reset pin in this manner? Any gotchas to be aware of?
1 Answer 1
No gotchas I can think of, except for the fact that the ATtiny's memory will be re-initialized every time you reset it. But I assume you are aware of that.
Note that, if you want some data to be preserved across a reset, it is possible using either the on-chip EEPROM or the .noinit section of the RAM.
-
You can also use the EEARL and EEARH registers to store 2 bytes between resets, as those retain their value between resets. This behavior however isn't specified in the datasheet, so not really advised for critical/professional applications.Gerben– Gerben2018年08月18日 18:28:41 +00:00Commented Aug 18, 2018 at 18:28