Everything

Usage example

Switch clock by external input.

 

[GUI setting example]

Clock Generator

Used

CGC

Used

Operation mode setting

High speed min mode 4.0(V) VDD 5.5(V)

Main system clock (fMAIN) setting

High-speed OCO(fIH)

fIH Operation

Used

fIH Frequency

64(MHz)

fMX Operation

Used

High-speed system clock setting

X1 oscillation(fX)

fMX frequency

4(MHz)

Stable time

65536 (2^18/fX) (μs)

fPLL operation

Unused

Main/PLL select clock (fMP) setting

64 (fMAIN)(MHz)

fSUB operation

Used

Subsystem clock (fSUB) setting

XT1oscillation(fXT)

fSUB frequency

32.768(kHz)

XT1 oscillator oscillation mode setting

Low power consumption

STOP

Subsystem clock in STOP, HALT mode setting

Internal low-speed oscillation clock (fIL) setting

15(kHz)

Low speed on-chip oscillatior clock (fSL) setting

32.768 (fSUB)(kHz)

WDT operation clock (fWDT) setting

15(kHz)

RTCoperation clock setting

32.768 (fSUB)(kHz)

Timer RD operation clock

64000 (fIH)(kHz)

CPU and peripheralclock setting (fCLK)

32000 (fMP/2) (kHz)

 

Interrupt

Used

INTP

Used

INTP0

Valid edge

Falling

Priority

Low

 

 

[API setting example]

r_main.c

void main(void)

{

       R_MAIN_UserInit();

       /* Start user code. Do not edit comment generated here */

       /* Clear INTP0 interrupt flag and enable interrupt */

       R_INTC0_Start();

 

       while (1U)

       {

              ;

       }

       /* End user code. Do not edit comment generated here */

}

 

r_cg_intc_user.c

/* Start user code for include. Do not edit comment generated here */

#include "r_cg_cgc.h"

/* End user code. Do not edit comment generated here */

 

/* Start user code for global. Do not edit comment generated here */

volatile uint8_t g_cgc_f = 0U;

/* End user code. Do not edit comment generated here */

 

static void __near r_intc0_interrupt(void)

{

       /* Start user code. Do not edit comment generated here */

       /* Change clock generator operation mode */

       if (0U == g_cgc_f)

       {

              if (MD_OK == R_CGC_Set_ClockMode(SUBXT1CLK))

              {

                     g_cgc_f = 1U;

              }

       }

       else

       {

              if (MD_OK == R_CGC_Set_ClockMode(HIOCLK))

              {

                     g_cgc_f = 0U;

              }

       }

       /* End user code. Do not edit comment generated here */

}