Pit Functional Description - Microchip Technology megaAVR 0 Series Manual

Hide thumbs Also See for megaAVR 0 Series:
Table of Contents

Advertisement

21.4.1
Initialization
To operate the RTC, the source clock for the RTC counter must be configured before enabling the RTC
peripheral, and the desired actions (interrupt requests, output Events).
21.4.1.1 Configure the Clock CLK_RTC
To configure CLK_RTC, follow these steps:
1.
Configure the desired oscillator to operate as required, in the Clock Controller peripheral
(CLKCTRL).
2.
Write the Clock Select bits (CLKSEL) in the Clock Selection register (RTC.CLKSEL) accordingly.
The CLK_RTC clock configuration is used by both RTC and PIT functionality.
21.4.1.2 Configure RTC
To operate the RTC, follow these steps:
1.
Set the Compare value in the Compare register (RTC.CMP), and/or the Overflow value in the Top
register (RTC.PER).
2.
Enable the desired Interrupts by writing to the respective Interrupt Enable bits (CMP, OVF) in the
Interrupt Control register (RTC.INTCTRL).
3.
Configure the RTC-internal prescaler and enable the RTC by writing the desired value to the
PRESCALER bit field and a '1' to the RTC Enable bit (RTCEN) in the Control A register
(RTC.CTRLA).
Note:  The RTC peripheral is used internally during device start-up. Always check the Busy bits in the
RTC.STATUS and RTC.PITSTATUS registers, also on initial configuration.
21.4.2
Operation - RTC
21.4.2.1 Enabling, Disabling, and Resetting
The RTC is enabled by setting the Enable bit in the Control A register (ENABLE bit in RTC.CTRLA to 1).
The RTC is disabled by writing ENABLE bit in RTC.CTRLA to 0.
21.5

PIT Functional Description

The RTC peripheral offers two timing functions: the Real-Time Counter (RTC) and a Periodic Interrupt
Timer (PIT). This subsection describes the PIT.
21.5.1
Initialization
To operate the PIT, follow these steps:
1.
Configure the RTC clock CLK_RTC as described in
2.
Enable the interrupt by writing a '1' to the Periodic Interrupt bit (PI) in the PIT Interrupt Control
register (RTC.PITINTCTRL).
3.
Select the period for the interrupt and enable the PIT by writing the desired value to the PERIOD bit
field and a '1' to the PIT Enable bit (PITEN) in the PIT Control A register (RTC.PITCTRLA).
Note:  The RTC peripheral is used internally during device start-up. Always check the Busy bits in the
RTC.STATUS and RTC.PITSTATUS registers, also on initial configuration.
21.5.2
Operation - PIT
21.5.2.1 Enabling, Disabling, and Resetting
The PIT is enabled by setting the Enable bit in the PIT Control A register (the PITEN bit in
RTC.PITCTRLA to 1). The PIT is disabled by writing the PITEN bit in RTC.PITCTRLA to 0.
©
2018 Microchip Technology Inc.
Configure the Clock
Datasheet Preliminary
®
megaAVR
0-Series
Real-Time Counter (RTC)
CLK_RTC.
DS40002015A-page 257

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the megaAVR 0 Series and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Atmega4808Atmega4809Atmega3208Atmega3209

Table of Contents