Example #1
0
/******************************************************************************
* ID           : 
*
* Include      : 
*
* Declaration  : bool R_PG_Clock_Stop_SUB(void)
*
* Function Name: R_PG_Clock_Stop_SUB
*
* Description  : Stop the sub-clock oscillator
*
* Arguments    : None
*
* Return Value : true  : Setting was made correctly.
*              : false : Setting failed.
*
* Calling Functions : R_CGC_Control
*
* Details      : Please refer to the Reference Manual.
******************************************************************************/
bool R_PG_Clock_Stop_SUB(void)
{
	return R_CGC_Control( PDL_CGC_SUB_CLOCK_DISABLE );
}
void ConfigureOperatingFrequency(void)
{
   bool err = true;

   //Configure the PLL to use the 20.0 MHz crystal as clock input
   err &= R_CGC_Set
      (
         PDL_CGC_CLK_MAIN,
         PDL_CGC_BCLK_DIV_1 | PDL_CGC_MAIN_RESONATOR,
         20E6,
         20E6,
         20E6,
         20E6,
         20E6,
         PDL_NO_DATA
         );

   /* Configure the clocks as follows -
    Clock Description              Frequency
    ----------------------------------------
    PLL Clock frequency...............100MHz
    System Clock Frequency.............50MHz
    Peripheral Module Clock B..........25MHz
    Peripheral Module Clock D..........50MHz
    FlashIF Clock......................25MHz
    External Bus Clock.................25MHz */

   err &= R_CGC_Set
      (
         PDL_CGC_CLK_PLL,
         PDL_CGC_BCLK_DIV_2,
         100E6,
         50E6,
         50E6,
         25E6,
         25E6,
         25E6
         );

   // Allow 100us for the main clock to stabilize
   err &= R_CMT_CreateOneShot
      (
         0,
         PDL_NO_DATA,
         100E-6,
         PDL_NO_FUNC,
         0
         );

   // Change to high-speed operating mode
   err &= R_LPC_Control(
      PDL_LPC_CHANGE_HIGH_SPEED
      );

   // Select the PLL as the clock source
   err &= R_CGC_Control
      (
         PDL_CGC_CLK_PLL,
         PDL_CGC_SUB_CLOCK_CL_STANDARD,
         PDL_CGC_SUB_CLOCK_ENABLE
         );

   while(!err)
      ;
}
Example #3
0
/******************************************************************************
* ID           : 
*
* Include      : 
*
* Declaration  : bool R_PG_Clock_Start_SUB(void)
*
* Function Name: R_PG_Clock_Start_SUB
*
* Description  : Start the sub-clock oscillator
*
* Arguments    : None
*
* Return Value : true  : Setting was made correctly.
*              : false : Setting failed.
*
* Calling Functions : R_CGC_Control
*
* Details      : Please refer to the Reference Manual.
******************************************************************************/
bool R_PG_Clock_Start_SUB(void)
{
	return R_CGC_Control( PDL_CGC_SUB_CLOCK_ENABLE );
}