Cannot init external 32 kHz crystal on ATxmega256A3BU

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

Hi fellows,

Previously used a ATxmega128A1 without any problems but the same code does not seem to work on a ATxmega256A3BU:

OSC.XOSCCTRL |= OSC_XOSCSEL1_bm; //Setup startup timer for 32 kHz.
OSC.CTRL |= OSC_XOSCEN_bm;       //External oscillator enabled. 
while ( (OSC.STATUS & OSC_XOSCRDY_bm) == 0); //Waiting for it to become stable

The AVR gets stuck on the last while statement, the xtal never seems to get stable.

Anything obvious I missed? Changed the fuse TOSCSEL to ALTERNATE.

Any ideas are welcome!
/Bjorn

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

Problem solved!

Module Access Enable bit must be set first:

VBAT.CTRL = VBAT_ACCEN_bm;

Not obvious in the documentation. Hope it helps anyone with the same problem.

Kind regards
Bjorn

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

I have the same problem but don't know where is VBAT defined. When compiling, 'VBAT' undeclared.

 

I'm using atxmega256a3bu.

 

thanks!