What should be considered when using PWM output function in the NuMicro? family?

Post Reply
a_ziliu
Posts: 208
Joined: 20 Mar 2017, 10:52

27 Mar 2017, 14:10

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:
Enable PWM clock:
CLK_EnableModuleClock(PWM0_MODULE);
Select PWM clock source:
CLK_SetModuleClock(PWM0_MODULE, CLK_CLKSEL2_PWM0SEL_PCLK0, NULL);
Reset PWM function:
SYS_ResetModule(PWM0_RST);
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;
Set the PWM output function:
PWM_ConfigOutputChannel(PWM0, 0, 180000, 50);
Enable PWM output:
PWM_EnableOutput(PWM0, PWM_CH_0_MASK);
Start the PWM output:
PWM_Start(PWM0, PWM_CH_0_MASK);

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests