よくある質問

FAQ

What should be considered when using PWM output function in the NuMicro® family?  Issue Date:2015-11-02

When using the PWM output function in the NuMicro® family, the users not only sets the corresponding pin to the PWM output function, but makes sure the PWM clock source is turned on, initializes and enables the PWM output function. Otherwise, the unstable state of the output pin may lead to leakage phenomenon.

 

In the M451 series, for example, the user can follow the steps below to set the PWM output function:

  1. Enable PWM clock:
    CLK_EnableModuleClock(PWM0_MODULE);
  2. Select PWM clock source:
    CLK_SetModuleClock(PWM0_MODULE, CLK_CLKSEL2_PWM0SEL_PCLK0, NULL);
  3. Reset PWM function:
    SYS_ResetModule(PWM0_RST);
  4. Set the pin or PWM function:
    SYS->GPC_MFPL = (SYS->GPC_MFPL & (~SYS_GPC_MFPL_PC0MFP_Msk));
    SYS->GPC_MFPL |= SYS_GPC_MFPL_PC0MFP_PWM0_CH0;
  5. Set the PWM output function:
    PWM_ConfigOutputChannel(PWM0, 0, 180000, 50);
  6. Enable PWM output:
    PWM_EnableOutput(PWM0, PWM_CH_0_MASK);
  7. Start the PWM output:
    PWM_Start(PWM0, PWM_CH_0_MASK);
Products: Microcontrollers ,Arm Cortex-M0 MCUs ,M051 Base Series ,M0518 Series ,M0519 Series ,Mini51 Base Series ,Nano100/102 Base Series ,Nano110/112 LCD Series ,Nano120 USB Series ,Nano130 Advanced Series ,NUC029 Series ,NUC100/200 Advanced Series ,NUC120/122/123/220 USB Series ,NUC130/230 CAN Series ,NUC131/NUC1311 CAN Series ,NUC140/240 Connectivity Series ,Arm Cortex-M4 MCUs ,M451 Base Series ,M451M Series ,M452 USB Series ,M453 CAN Series ,NUC442/472 Series ,NUC505 Series
Applications:
Function: Peripherals,Timer and PWM,PWM Output