lpcware

Modify Clock with PLL0 in operation

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Cleiton Bueno on Mon Nov 17 11:24:23 MST 2014
Hello!

I have an LPC1788, working perfectly using the MAIN CLOCK with external oscillator, but now I want to reduce the clock at one time and wanted to do with PLL0.
But my firmware is crashing when put to rotate the function of reducing the clock.

What I'm doing:
void ClockModify( uint32_t MValue, uint32_t PValue) {


  /* 1. make sure the PLL output is not already being used */

  LPC_SC->CLKSRCSEL = LPC_SC_CLKSRCSEL_CLKSRC_RC; /* set internal RC as clock source */


  LPC_SC->PLL0CON = 0;                /* disable PLL0 */
  pll0_feed();                                      // Apply modify in clock PLL0 
  LPC_SC->SCS |= (1 << 5);         
  while(((LPC_SC->SCS & (1 << 6)) == 0));       /* wait for main oscillator to start up */


  LPC_SC->CLKSRCSEL = LPC_SC_CLKSRCSEL_CLKSRC_MAIN;


  LPC_SC->PLL0CFG = (MValue << 0) | (PValue << 5);    
  pll0_feed();           // Apply modify in clock PLL0                                                                   

  LPC_SC->PLL0CON = 1;                                        
  pll0_feed();          // Apply modify in clock PLL0                                                          

  /* 4. set up clock dividers */
  LPC_SC->CCLKSEL = (1 << 0);        

  /* 5. wait for PLL to lock */
  while( ((LPC_SC->PLL0STAT & (1 << 10)) == 0) );  


  LPC_SC->CCLKSEL |= (1 << 8);

  pll0_feed();
}


Help?

Outcomes