AVR32UC3B Clock Setup without ASF

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

Hello community,

 

currently I'm taking my first steps with the AVR32. I soldered the AVR32UC3B on an adapter for breadboard use. Now I want to use a 12MHz crystal on PA18/19 (oscillator0) to get the chip working with 60Mhz. After reading chapter 9 (Power Manager) of the manual I created that code:

 

int main(void)
{
	AVR32_PM.MCCTRL.osc0en = 1;
	AVR32_PM.OSCCTRL0.mode = 7;
	AVR32_PM.OSCCTRL0.startup = 0;

	while(!AVR32_PM.POSCSR.osc0rdy)
	{
		;
	}

  	AVR32_PM.PLL[0].pllcount = 16;
  	AVR32_PM.PLL[0].pllmul = 9;
  	AVR32_PM.PLL[0].plldiv = 1;
  	AVR32_PM.PLL[0].pllopt = 1;
  	AVR32_PM.PLL[0].pllosc = 0;
	AVR32_PM.PLL[0].pllen = 1;

   	while(!AVR32_PM.POSCSR.lock0)
   	{
   		;
   	}
	AVR32_PM.MCCTRL.mcsel = 2;

	AVR32_GPIO.port[0].gpers = (1 << 31);
	AVR32_GPIO.port[0].oders = (1 << 31);
	AVR32_GPIO.port[0].ovrs = (1 << 31);

    while (1)
    {

		AVR32_GPIO.port[0].ovrt = (1 << 31);
    }
}

From what I understood, this should result in a PLL frequency of 120Mhz (12 / 1 * 10). But the PLL lock flag never gets set. So, how do I configure the PM correctly for higher frequencys? And when do I set the CPU/PBA/PBB frequencys?

Last Edited: Mon. Jun 12, 2017 - 07:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know you don't want to use ASF but might it not be an idea to actually sketch out what you are trying to achieve here in ASF and then see what register writes it makes to see how that compares to what you are trying?

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

That is a good idea! I will try to do that. Well I just thought, that I'm missing a line or two of code and things work.

 

The code works. I connected 3V3 to VDDPLL, but it requires 1V8. I switched cables and now I can see a 6 MHz square wave on PA31

Last Edited: Mon. Jun 12, 2017 - 07:31 PM