牛卧堂MCU技术交流
标题:
为什么M0518的PF5配成PWM输出一直输出0V
[打印本页]
作者:
匿名
时间:
2024-5-11 23:32
标题:
为什么M0518的PF5配成PWM输出一直输出0V
/* Enable PWM1 clock source */
CLK_EnableModuleClock(PWM1_MODULE);
/* Select PWM module clock source */
//CLK_SetModuleClock(PWM0_MODULE, CLK_CLKSEL3_PWM0_S_HClK, 0);
CLK_SetModuleClock(PWM1_MODULE, CLK_CLKSEL3_PWM1_S_PCLK, 0);
/* Reset PWM0 */
SYS_ResetModule(PWM1_RST);
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate PllClock, SystemCoreClock and CycylesPerUs automatically. */
//SystemCoreClockUpdate();
PllClock = PLL_CLOCK; // PLL
SystemCoreClock = PLL_CLOCK / 1; // HCLK
CyclesPerUs = PLL_CLOCK / 1000000; // For SYS_SysTickDelay()
/* Set GPA multi-function pins for PWM1 Channel 2 */
SYS->GPA_MFP &= ~(SYS_GPA_MFP_PA10_Msk);
SYS->GPA_MFP |= (SYS_GPA_MFP_PA10_PWM1_CH2);
/* Set GPA multi-function pins for PWM1 Channel 5 */
SYS->GPF_MFP &= ~(SYS_GPF_MFP_PF5_Msk);
SYS->GPF_MFP |= (SYS_GPF_MFP_PF5_PWM1_CH5);
SYS->ALT_MFP3 |= SYS_ALT_MFP3_PA10_PWM1_CH2;
SYS->ALT_MFP3 |= SYS_ALT_MFP3_PF5_PWM1_CH5;
PWM_ConfigOutputChannel(PWM1, 2, 100, 99);
PWM_EnableOutput(PWM1, PWM_CH_2_MASK);
PWM_Start(PWM1, PWM_CH_2_MASK);
PWM_ConfigOutputChannel(PWM1, 5, 1000, 55);
PWM_EnableOutput(PWM1, PWM_CH_5_MASK);
PWM_Start(PWM1, PWM_CH_5_MASK);
为什么PWM1_CH2输出正常可控, 但PWM1_CH5输出一直为0V?
作者:
chrishu
时间:
2024-5-13 15:44
看起来配置是对的。是不是其他代码里将PF5配置成了其他功能?附件是我这里测试正常的代码
main.zip
(2.22 KB, 下载次数: 141)
2024-5-13 15:44 上传
点击文件名下载附件
欢迎光临 牛卧堂MCU技术交流 (http://nuvoton-mcu.com/)
Powered by Discuz! X3.2