Hey,
!!! Code on the first comment because of character restriction !!
I am trying to put my Attiny2313 to sleep.
Actually I think I managed to put it to sleep but I am having issue waking it up.
I have watched numerous tutorials and exemples on how to put an attiny (85 mostly, because nobody is using 2313) or arduino to sleep (since I use to arduino IDE and DrAzzy's work to programm my attiny2313).
About my program:
When I press a button, on release, a number between 1 and 6 (included) is displayed ona 7 segment display.
If no interrupt is triggered (button is released) in the last 5 seconds, the display turns black and the device goes to sleep.
When the button is pressed again, it wakes up and display a new number. (the part I can't achieve).
Issue:
Once the the display turns black (and most likely the attiny goes to sleep), the display stays black even after pressing the push button.
What I have done:
I have read threads such as:
https://www.avrfreaks.net/forum/sleep-mode-and-attiny2313
And looked at all sentences including "sleep" in the datasheet.
In the tutorials it is explained that the Attiny goes to sleep after the command sleep_mode();
It is then woken up by the interrupt calling the (empty) function wake_up. In the datasheet it is explained that the trigger of an interrupt will stop the sleep, that's why wake_up() is empty.
When it wakes up, it continue the script from where it left, so it will run the code under "sleep_mode();", that's why we disable sleep mode after "sleep_mode();".
I also tried to put "sleep_disable();" in the wake_up function just to be sure. But it doesn't change anything.
I also tried to use the functions from the data sheet such as:
SM0 |= (1<<SM0); //sleepmode to power down
SE |= (1<<SE); //sleep enabled
__sleep(); //enter sleep
but I get those compiling error messages:
In function 'void loop()':
DeElectroniqueV2:52:19: error: lvalue required as left operand of assignment
SM0 |= (1<<SM0); //sleepmode to power down
^
DeElectroniqueV2:53:17: error: lvalue required as left operand of assignment
SE |= (1<<SE); //sleep enable enabled
^
DeElectroniqueV2:54:5: error: '__sleep' was not declared in this scope
__sleep(); //enter sleep
^~~~~~~
exit status 1
lvalue required as left operand of assignment
I hope it is clear and that you can help me! ![]()