Does ATXmega128A3U really run at 48MHz when using RC32M for USB clock

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

Hello All,

I am trying to understand exactly how fast the micro is running (what is ClkCPU) when using RC32M for the USB clock 

I am confused, as it appears that the micro is running at 48MHz - however the datasheet seems to indicate that 32MHz is the max CPU clock frequency!?

What am I missing?

 

I am using ASF to generate the code required for USB.

 

FWIW: This is the relevant bits from Conf_clock.h

#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_RC32MHZ
/* Fbus = Fsys / (2 ^ BUS_div) */
#define CONFIG_SYSCLK_PSADIV          SYSCLK_PSADIV_1
#define CONFIG_SYSCLK_PSBCDIV         SYSCLK_PSBCDIV_1_1

#define CONFIG_USBCLK_SOURCE                USBCLK_SRC_RCOSC
#define CONFIG_OSC_RC32_CAL                 48000000UL
#define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC  OSC_ID_USBSOF

The things runs fine but I am concerned that/if I am running so far out of spec.

 

Regards,

Ivan  Vernot

//realtimedesigns.com.au

 

*This is about the XMega, so it is moved to the XMega forum. Moderator.*

 

 

Last Edited: Tue. Jun 16, 2015 - 04:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know Xmega (or ASF) very well but when I look at the AU manual the diagram seems to suggests that after the PLL the clock splits to SCLKSEL and USBSRC. The USB then has it's own prescaler which presumably takes the 48 back down to 12. On the SCLKSEL side of things there are then the "System clock prescalers" (A, B and C) that take that input and finally produce clkPer(N) and clkCpu from it. So I think that even if you route 48MHz as the input the idea is that you should be setting prescalers there to ensure that the clkCpu is actually brought into the safe 0..32MHz operating range. It would be unwise to run at the full 48MHz because the flash execution access is not spec'd for that speed.

 

Having said all that I haven't yet stumbled upon anything in the datasheet (either the generic one or the chip specific one) that actually says clkCpu should not exceed 32MHz. The documentation for Xmega (unlike Tiny/Mega) is VERY irritating!

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

Basically the "32MHz RC oscillator" can actually be tuned to run up to 48MHz. It's more like a "high frequency RC oscillator", the name is misleading. The ASF code loads a value into the calibration register that produces 48MHz.

 

Atmel state that the maximum CPU frequency for XMEGA parts is 32MHz. So when using the "RC32M" oscillator as the CPU clock and USB clock you need to set the divider to 2. That then gives you 48MHz for USB and 24MHz for the CPU and other peripherals. The limit is given in the datasheet for the part you have, e.g. in the E5 datasheet it is table 36-2.

 

Of course, if you actually try to run the XMEGA CPU at 48MHz it will probably work. I've tested one up to 64MHz, and found it to work up to about 60MHz without any noticeable issues. I didn't do a thorough test though, and that's the problem. Atmel don't guarantee anything above 32MHz, so for example you might find that the ADC gives bad readings or TWI doesn't work. Best to stick to 32MHz maximum.

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

Thank you all for taking the time to respond.

@mojo-chan I saw the 32MHz limit in the data sheet also. I understand that it possible to divide down the USB clock to get a 24MHz CPU clock - I was hoping to run the CPU clk at 32MHz though.

@clawson I agree - the docs  are quite dense and the ASF, although voluminous, is almost impenetrable. Still we have the source code so the information is there :-)

FWIW I have an external 12MHz xtal available..

I have been reading about PLL and looks like I should be able to run the CPU clk off the XTAL and the USB off the RC32M. But how to coax ASF Conf_Clk.h to do so it the challenge for me!

 

More reading to be done...

 

Thanks again..

Ivan

 

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

Very simple. Just output system clock on pin PC7 and measure it with scope.

 

PORTC.DIRSET = 0x80;
PORTCFG.CLKEVOUT = 0x01;

You can also in theory output clock X2 and X4, but for my XMEGA128A1U X2 clock is npt outputted on pin, though internally everything works OK.

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

I understand that it possible to divide down the USB clock to get a 24MHz CPU clock - I was hoping to run the CPU clk at 32MHz though

To achieve that I guess you need the PLL to multiply up to a frequency that has both 32 and 48 as factors. 96MHz would appear to meet that requirement. Divide it by 3 for the 32MHz and by 2 for the 48MHz.

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

clawson wrote:

To achieve that I guess you need the PLL to multiply up to a frequency that has both 32 and 48 as factors. 96MHz would appear to meet that requirement. Divide it by 3 for the 32MHz and by 2 for the 48MHz.

 

I wish, I could... Unfortunately you can multiply by any integer number in range 2..31, but you can divide PLL by 2 only. 48 * 4 = 188MHz would do, but PLL is 128MHz only :(

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

Unless USB was only ever a late add-on it does seem kind of curious that Atmel would not have included clock options to cater for 32 to the CPU and 48 to the USB?!?

 

EDIT: I thought Atmel might have a "best practice" application note but the closest I can find is this:

 

http://www.atmel.com/Images/doc8...

 

which seems less than helpful frown

Last Edited: Tue. Jun 16, 2015 - 11:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm. As I understand you can run CPU at 32MHz and have onboard USB enabled, but you must use detailed above clocking (XTAL -> PLL -> CPU, RC32M -> RC48M -> USB). You can not use single clock source and have USB and max CPU speed, 24MHz only.

 

PLL should have had "DIVIDE BY 3" option :(

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

Can't you do this then...

 

 

(Thus proving that my graphic editing skills know no bounds!)

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

I don't argue about calculation and your intension. I simply do not know how to divide PLL output by 3.

Have a look at PLLCTRL register:

 

7:6 PLLSRC (XTAL/RC)

   5 PLLDIV (factor of 2 only)

4:0 PLLFAC (multiplication only)

 

You can divide this clock further by 2 or 4, but not by 3.

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

Well, you could use the RC32M oscillator at 48MHz for USB and the RC2M oscillator and PLL to generate 32MHz for the CPU.

 

Or use the 12MHz xtal multiplied up to 48MHz for USB (good idea, it's more stable than the RC) and then use the RC32M at 32MHz for the CPU.

 

Or some other combination... There are lots of ways to get almost any combination of speeds you want. Keep in mind though that if you want to use USB Full Speed (12Mb/sec) you need a CPU clock of at least 12MHz.

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

Your graphic editing skills are truly sublime!

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.