Problem with RTC power reduction

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am having another odd issue with a 128A3U...

	PR.PRGEN	= PR_AES_bm | PR_DMA_bm;

	// start RTC
	while (RTC.STATUS & RTC_SYNCBUSY_bm)	// essential to wait for this condition or the RTC doesn't work
		;
	RTC.PER		= 1023;						// 1Hz
	RTC.CNT		= 0;
	RTC.INTFLAGS = 0xFF;
	RTC.INTCTRL = RTC_OVFINTLVL_LO_gc;
	RTC.CTRL = RTC_PRESCALER_DIV1_gc;

The above code does not work. RTC.CTRL remains at 0x00 and the RTC does not run.

The following code does work:

	PR.PRGEN	= PR_AES_bm | PR_DMA_bm;

	PR.PRGEN &= ~PR_RTC_bm;

	// start RTC
	while (RTC.STATUS & RTC_SYNCBUSY_bm)	// essential to wait for this condition or the RTC doesn't work
		;
	RTC.PER		= 1023;						// 1Hz
	RTC.CNT		= 0;
	RTC.INTFLAGS = 0xFF;
	RTC.INTCTRL = RTC_OVFINTLVL_LO_gc;
	RTC.CTRL = RTC_PRESCALER_DIV1_gc;

RTC.CTRL becomes 0x01 and the RTC runs as normal.

I have verified that in both cases PR.PRGEN is 0b00010001, so the RTC should be powered up.

I checked the generated assembler and it is definitely writing to the registers. The exact same code seems to work okay on a 128D3.