I am fairly new to the Arduino world, but not so much to embedded programming.
I am working with Nano Every boards (atmega4809) and 3.3v compatibles (atmega4808).
My interest is timing and sleep modes.
I have been looking for succinct documentation and examples for using these features for a couple of months now, and have become frustrated. What I need is a clear explanation of the 'Arduino way' to interact with the low level registers that control these features. I also would like to see the constants and their build-time values that are routinely used with these registers. I do not know where to look.
What I want to do is well defined. I want to use the suspend and deep sleep modes for sub 1 second periods (i.e. 600 ms) and then to return to normal execution via an interrupt or an event interrupt.
I have mostly settled on using the MegaCoreX library, though I have also worked with the RocketScream_RTCAVRZero-1.0.0 library as well. The latter is very helpful if you want to use the suspend mode, but only for periods > 1s.
I have found the example in "Getting Started with Real-Time Counter (RTC)" , Microchip's TB3213. It is very helpful and contains an example that comes close to what I need - Appendix : "Example 7-3. RTC PIT Wake from Sleep Code Example". It depends on a call to ccp_write_io(), which, not surprisingly, is not available to the linker used by the Arduino environment.
The only hint f these things that I can find comes by grepping my entire system. I seem only to find them in the MegaCoreX source keywords.txt file, which gives me no information about what the represent.
My best guess at this point is that -as in the RocketScream_RTCAVRZero-1.0.0 library, one combines the desired constants and assigns them to CLKCTRL as in:
temp &= ~CLKCTRL_ENABLE_bm;
temp = CLKCTRL.XOSC32KCTRLA;
CLKCTRL.XOSC32KCTRLA = temp;
But where is CLKCTRL described, and where are the available constants described, and how to apply them? I see much of the information described in an abstract way in the datasheets and the technical bulletins, but it really doesn't tell me how to do it the 'Arduino way'.
I'm sure that all of this is down to my lack of deep knowledge of how Arduino conventions have evolved over time.
Can anyone help me get a clue?
