Attiny402 RTC Configuration

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hi,

 

I'm stating developing for attiny402. Reading the datasheet it says to 22.3.1.1 Configure the Clock CLK_RTC however look into CLKCTRL I can't find anything to configure CLK_RTC. I did read the Getting started but since it is for a different part with external 32khz crystal I'm having trouble to get RTC configured and working.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I suppose they mean this, not that there is much to configure, just one bit. Probably the best thing to do is leave it as default.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>I can't find anything to configure CLK_RTC

 

They have the same paragraph in other datasheets where it makes a little more sense. In other variations, they have the option to use an external crystal, which has to be enabled in clkctrl.

 

In your case, setting RTC.CTRLA RTCEN to 1 is all you need to get started. The counter will be running at full speed (32khz), and you can read CNT to check it. Once that is done you proved that the counter is moving, then you can start to use all its other features.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would just like to add a small note to what the guys said here. remeber that in order to get the RTC functions as desired, all the other bits must be set first, and ONLY after that you can enable the RTCEN in CTRLA as cutvm said, this is done in this way:

 

RTC.CTRLA |= (1 << RTC_RTCEN_bp);

if you would like to use the internal low power oscillator then you have to set the CLKSEL, and ofcurse before enablig the RTC:

 

RTC.CLKSEL = RTC_CLKSEL_INT32K_gc; /* 32KHz Internal Ultra Low Power Oscillator (OSCULP32K) */

 

Last Edited: Mon. Oct 14, 2019 - 08:03 AM