RTC interrupt register not recognised

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

Hello Everyone,

I have only just started with ATXMega but used to use ATMEGA. I am using the ATXMEGA256-A3BU Xplained eval board and just trying to get the RTC working with an external 32.768kHz.

I am trying to set the RTC interrupt control register but the compiler says it is undeclared.

#include 
#include "asf.h"
#include 

	//////	OSCILLATOR CONFIGURATION   ////////
	CLK_CTRL = (1<<CLK_SCLKSEL0_bp)|(1<<CLK_SCLKSEL1_bp);	     //CLK Source External OSC
	CLK_RTCCTRL = (1<<CLK_RTCSRC0_bp)|(1<<CLK_RTCSRC2_bp)|(1<<CLK_RTCEN_bp);  
				 
	OSC_XOSCCTRL = (1<<OSC_XOSCSEL1_bp)|(1<<OSC_X32KLPM_bp);
	OSC_CTRL = (1<<OSC_XOSCEN_bp);

	RTC_INTCTRL = 0x03;

The specific issue is with RTC_INTCTRL
For the interrupt routine ISR(RTC_OVF_vect){} is not recognised either.

I am wondering if anyone has seen an issue like this before? What would onedo to fix this?

Thanks
Aaron

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

What version of Atmel Studio?

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

A machine I have here has 3.4.1051 and says this:

C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1051\avr8-gnu-toolchain\avr\include\avr>grep 0x0402 iox*
iox128a1.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128a1u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128a3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128a3u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128a4u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128b1.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128b3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox128d4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox16a4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox16a4u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox16c4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox16d4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox16e5.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox192a3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox192a3u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox192c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox192d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox256a3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox256a3u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox256c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox256d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32a4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32a4u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32c4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32d4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox32e5.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox384c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox384d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64a1.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64a1u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64a3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64a3u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64a4u.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64b1.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64b3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64c3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64d3.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox64d4.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)
iox8e5.h:#define RTC_INTCTRL  _SFR_MEM8(0x0402)

iox256a3bu.h is rather notable by its absence there. I've rather lost the will to live when it comes to Atmel's convoluted scheme for Xmega model numbers but remind me again what does the added "B" between 256a3u and 256a3bu mean?? Could it be B for "RTC is Buggered up" or something?

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

Ah ha! "diff" (well kdiff3 in fact) reveals all. The B is clearly for "Battery" and the chips differ in that the B part has a lot definitions for "VBAT". It also renames "RTC" to "RTC32" and that device moves from a base address of 0x400 for RTC to 0x420 or RTC32

It also appears to have lost the base address fro USARTE1 and SPIE so I guess this "VBAT" thing replaces those on PORTE pins?

Anyway OP wants to explore RTC32 not RTC.

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

The RTC32 is not the same as the normal 16 bit RTC. If it only has an RTC32 then the OP will have to write some different code, or switch to the AU version.

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

Thank you all for your replies,

I am using AVR Studio 6.1

Initially I was going to use the 32bit RTC however because I didn't need all 32bits I thought I would use the 16bit RTC because it was in the datasheet and there was some reference to it in the "io" header upon a quick look. Then as I found out the hard way there are gaps in the header file....

It is strange there would be remnants of the 16bit RTC timer in the header

In regards to what the difference is I agree that there is a VBAT port which powers the RTC when the rest of the system is shutdown.