ATMEGA 4809 - wrong information in datasheet?

Hello All,
I have ATMEGA 4809 in DIP40 package and I tried RTC with Overflow Interrupt and PIT Interrupt.
Hardware: only ATMEGA 4809 with LED diodes. RED LED is connected to digital pin 7 and BLUE RED is connected to digital pin 6. For programming I am using JTAG2UPDI with MegaCoreX core with option No bootloader.
It is working OK.
I tried small code, which do nothing (CPU is sleeping). CPU should be woke up with two kinds of interrupts:

  1. Overflow Interrupt from RTC each 2 seconds => BLUE LED is toggled.
  2. PIT Interrupt from RTC each 4 seconds => RED LED is toggled.

Here is source code:

#include <avr/sleep.h>
#include <avr/interrupt.h>

const unsigned int RTC_EXAMPLE_PERIOD = 16;
const byte RED_LED = 7;
const byte BLUE_LED = 6;

void RTC_init(void) {
  while (RTC.STATUS > 0) {
    ;                                   /* Wait for all register to be synchronized */
  RTC.PER = RTC_EXAMPLE_PERIOD;         //  set period
  RTC.CLKSEL = RTC_CLKSEL_INT1K_gc;     /* 32.768kHz Internal Oscillator with divider 32, it means 1024 Hz */
  RTC.DBGCTRL |= RTC_DBGRUN_bm;         /* Run in debug: enabled */
  RTC.CTRLA = RTC_PRESCALER_DIV128_gc   /* into RTC goes now 1024/128 = 8 Hz clock. Overflow interrupt will happens each 2s, because period is set to 16 RTC cycles (RTC.PER)*/
              | RTC_RTCEN_bm            /* RTC Enable: enabled */
              | RTC_RUNSTDBY_bm;        /* Run In Standby: enabled */
  RTC.PITINTCTRL = RTC_PI_bm;           /* Enable PIT Interrupt */
  RTC.PITCTRLA = RTC_PERIOD_CYC32_gc    /* RTC Clock Cycles 32, PIT interrupt should happen each 4 second */
              | RTC_PITEN_bm;           /* Enable PIT counter: enabled */
  RTC.INTCTRL |= RTC_OVF_bm;            /* Enable Overflow Interrupt */

ISR(RTC_CNT_vect) {
  RTC.INTFLAGS = RTC_OVF_bm;          /* Clear interrupt flag by writing '1' (required) */
  digitalWrite(BLUE_LED, CHANGE);

ISR(RTC_PIT_vect) {
  digitalWrite(RED_LED, CHANGE);

void setup() {
  RTC_init();                           /* Initialize the RTC timer */
  pinMode(RED_LED, OUTPUT);                   /* Configure pin#7 as an output */
  pinMode(BLUE_LED, OUTPUT);
  SLPCTRL.CTRLA &= B11111011;      // next two rows set sleep mode (STANDBY) and enable sleep
  SLPCTRL.CTRLA |= B00000011;

void loop() {

What is expected:

  1. BLUE LED should light 2 seconds and then 2 seconds not and repeat it ...
  2. RED LED should light 4 seconds and then 4 seconds not and repeat it

What is real result:

  1. BLUE LED lights 2 seconds and 2 seconds not - as expected.
  2. RED LED lights 0,0625 s and 0,0625s not. (Interrupt 32 times per second) It's bad ...

It means, prescaler is not used for PIT (but is working correctly for CNT counter in RTC). According datasheet (
prescaler should be common for CNT and PIT (see picture 22.1 in datasheet on page 255).

For me it seems so, as I drew in picture in attachments.
It's also possible, I am wrong and prescaler can be turned on/off for PIT ... but I didn't find such possibility in datasheet.
Do you have any info about prescaler for RTC and PIT? Is it really so, prescaler can't be used with PIT?
Thank you in advance.
Best Regards

There is a mention in the errata for that MCU concerning the RTC; you should check if it is relevant to your problem:

2.5 RTC
2.5.1 Any Write to the RTC.CTRLA Register Resets the RTC and PIT Prescaler
Any write to the RTC.CTRLA register resets the RTC and PIT prescaler.

Work around

Affected Silicon Revisions
Rev. A Rev. B

  • X

Hi arduarn,
thank you for answer. For PIT, yes it's relevant. I tried PIT in another sketch and if I wrote anything to RTC.CTRLA, interrupt didn't happens.
Just now I tried also another chip - ATMEGA 4808 and there is the same behavior. Therefore it seems really as problem with silicon.
Thank you again.