-
Hi everyone, I'm trying to make the RTC prescaler work but even though I set up the RTC.CTRLA register as datasheet says, nothing changes. I use the example which is mentioned in: If anyone has a solution or a good example how to make the attiny sleep more than 32s(the max without prescaler) please tell. I already write a function which counts wake ups and sleep the MCU back if the desired sleep time is not reached, but it's still waking up the MCU to sleep it back. @SpenceKonde you might know this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I never use the sleep function, but you can prescale the RTC to trigger an interrupt for example once in a couple of hours The PIT can only do once every 32 seconds max, but the RTC_CNT interrupt can be set for hours. In below example I set the RTC to use the 1KHz clock signal and then count to 1000. Without prescaling that takes one second. In the example I prescale with 64, so it takes 64 seconds between a RTC_CNT interrupt to occur. Visualizeing by toggling a led on PB0. If you set it to If that's still not enough, you increase the counter to count to 5000, to get 45 hours, etc...
|
Beta Was this translation helpful? Give feedback.
-
Awesome, thank you very much! I will try this out |
Beta Was this translation helpful? Give feedback.
I never use the sleep function, but you can prescale the RTC to trigger an interrupt for example once in a couple of hours
The PIT can only do once every 32 seconds max, but the RTC_CNT interrupt can be set for hours. In below example I set the RTC to use the 1KHz clock signal and then count to 1000. Without prescaling that takes one second. In the example I prescale with 64, so it takes 64 seconds between a RTC_CNT interrupt to occur. Visualizeing by toggling a led on PB0.
If you set it to
RTC_CTRLA |= RTC_PRESCALER_DIV32768_gc | RTC_RTCEN_bm; // turn on RTC ansd set RTC prescaler factor
It is going to take 32768 seconds, which is a little over 9 hours.If that's still not enough, you in…