ATxmega256A3U-AU Clock Issue.

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

Hi all, We are using ATxmega256A3U-AU in our latest project and we are using an external clock by using a crystal - NX3225GA-16.000M-STD-CRG-1, but we are facing a problem by not getting an external clock and our micro controller is working only through internal clock.

Now my question is can somebody help me to get my external clock through the crystal. What are all the design constraints to be followed to achieve it.

 

Thank you.

 

Regards,

Amarnath G

+91 9790526746

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

Greg Muth

Portland, OR, US

Xplained Boards mostly

Atmel Studio 7.0 on Windows 10

 

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

Perhaps if you show your clock setup routines someone will spot a problem...

David (aka frog_jr)

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

Remember, you have to set/clear/whatever a bit in the Configuration Protection Register in order to change the clock.

 

JC

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

Here is an example of changing the clock, albeit in Basic:

This changes to another internal clock source, but the concept is the same for the other clock sources.

 

JC

 

Clockopt5:
   'Set up the Xmega Clock.
   'Run at 32 MHz from the Internal 32 MHz Osc, set by my code.
   'Xmega runs on Int 2MHz Osc on Startup.
   'This turns on the Int 32 MHz Osc, awaits it being ready, and switches to it.
   'Don't forget the Configuration Change Register Protection Trigger before
   'changing the uC's Clock Source.
   'First turn ON the 32 MHz Int Osc:
   'They wait until the Int 32 MHz Osc is ready to be used.
   Osc_ctrl = 2                                             'Int 32 MHz Osc ON
   Rvbit = 0                                                'Clear flag
   While Rvbit = 0
      'Read the Int 32 MHz Osc Status
      Regdata = Osc_status                                  'Status of all Int Osc Sources
      Rvbit = Regdata.1                                     'Int 32 MHz Osc Status, 1 = Ready
   Wend
   Cpu_ccp = 216                                            'Config Change Protection
   Clk_ctrl = 1                                             'Use Int 32 MHz Osc
   Return

 

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

You need to configure the external oscillator via XOSCCTRL, particularly the start-up time and oscillator selection.

 

Are you sure that the config change protection is working? I don't know what the compiler spits out but maybe it's not efficient enough.

 

Can you use the debugger to see what is not changing?