呜呼噜噜 2022-11-02 18:20 采纳率: 40%
浏览 13
已结题

GD32E230PWM输出波形

请问GD32E230PWM输出波形怎么调成直上直下的
void timer_config(void)
{
timer_oc_parameter_struct timer_ocintpara;
    timer_parameter_struct timer_initpara;

    rcu_periph_clock_enable(RCU_TIMER16);

    timer_deinit(TIMER16);

    /* TIMER configuration */
    timer_initpara.prescaler         = 7200; 
    timer_initpara.alignedmode       = TIMER_COUNTER_EDGE;
    timer_initpara.counterdirection  = TIMER_COUNTER_UP;
    timer_initpara.period            = 4000; 
    timer_initpara.clockdivision     = TIMER_CKDIV_DIV1;
    timer_initpara.repetitioncounter = 0;
    timer_init(TIMER16,&timer_initpara);

    /* configurate CH0 in PWM mode0 */
    timer_ocintpara.outputstate  = TIMER_CCX_ENABLE;
    timer_ocintpara.outputnstate = TIMER_CCXN_DISABLE;
    timer_ocintpara.ocpolarity   = TIMER_OC_POLARITY_HIGH;//极性为高 占空比内高电平
    timer_ocintpara.ocnpolarity  = TIMER_OCN_POLARITY_HIGH;
    timer_ocintpara.ocidlestate  = TIMER_OC_IDLE_STATE_LOW;
    timer_ocintpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;

    timer_channel_output_config(TIMER16,TIMER_CH_0,&timer_ocintpara);

    timer_channel_output_pulse_value_config(TIMER16,TIMER_CH_0,1000); // 50% duty
    timer_channel_output_mode_config(TIMER16,TIMER_CH_0,TIMER_OC_MODE_PWM0);
    timer_channel_output_shadow_config(TIMER16,TIMER_CH_0,TIMER_OC_SHADOW_DISABLE);

    /* auto-reload preload enable */
    timer_auto_reload_shadow_enable(TIMER16);
//    timer_automatic_output_enable(TIMER16);
    timer_primary_output_config(TIMER16,ENABLE);
    /* auto-reload preload enable */
    timer_enable(TIMER16);
}

上面代码运行结果用示波器打出来是这样

img

怎样能做到输出波形是没有滑下来的那条线
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 11月11日
      • 已采纳回答 11月3日
      • 创建了问题 11月2日

      悬赏问题

      • ¥100 c/c++实现DoubleArrayTrie
      • ¥30 关于#网络安全#的问题:非对称加密验证
      • ¥20 关于线性代数里施密特正交化和QR分解的疑问
      • ¥15 matlab超类包含解析错误
      • ¥15 python拖拽文件问题
      • ¥15 执行import paddle代码出现错误如何解决?
      • ¥15 hisat2align exited with value 137
      • ¥15 寻找大学生合作开发软件(Delphi)
      • ¥30 AndroidBench&eMMC内存测试速度&Android
      • ¥15 W10 文件共享失败 怎么解决