ATSAM4S2A PLL not locking or unlocking

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using the Atmel ATSAM4S2A with a 11 MHz crystal connected. I want to use the PLL to make a 110MHz MCK. The crystal clock is output on PCK0 and is ok. The PLL sometimes locks, but immediately unlocks again.

The clock init code:

 

void Init_Clock(void) {

	REG_PMC_WPMR = PMC_WPMR_WPKEY_PASSWD;

	// Set Flash WaitStates
	REG_EFC0_FMR |= (EEFC_FMR_FWS(5) | EEFC_FMR_CLOE);

	// Enable Crystal Oscillator
	PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCXTST(0xFFul) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
	while (!(REG_PMC_SR & PMC_SR_MOSCXTS));
	
	//Select Crystal for Main Clock
	PMC->CKGR_MOR = CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCXTST(0xfful) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
	while (!(REG_PMC_SR & PMC_SR_MOSCSELS));
	
	//Write PLL Value (11.2896MHz * 10/1 = 112.896MHz)
	PMC->CKGR_PLLAR = CKGR_PLLAR_ONE | (CKGR_PLLAR_MULA(0x9ul) | CKGR_PLLAR_DIVA(1ul) | CKGR_PLLAR_PLLACOUNT(0x3ful));
	while (!(REG_PMC_SR & PMC_SR_LOCKA));
		
	PMC->PMC_MCKR = PMC_MCKR_PRES_CLK_1 | PMC_MCKR_CSS_PLLA_CLK;
	while (!(REG_PMC_SR & PMC_SR_MCKRDY));

	// Select Main Clock for PCK0:
	REG_PMC_PCK = PMC_PCK_CSS_MAIN_CLK;
	
	// Enable Clock Output on PCK0
	REG_PMC_SCER |= (1 << 8);
}

VDDPLL is connected to VDDOUT. I tried to decouple the VDDPLL input according to the AT03463 checklist, but it made no difference. Currently I just have one 100nF on the VDDPLL pin.

 

Any help will be highly appreciated!