-
GD32F303芯片,需通过死区时间调整pwm输出;请各位大神支招
我在使用GD32F303芯片时,通过TIMER0实现通道0互补输出,通过设置死区时间调整占空比;发现在设置死区时,占空比输出不理想,请问下,对于GD32F303芯片,有什么措施改善该问题吗?为了验证该问题,我做了如下测试:1.在timer0初始化时,将死区设为固定的值如245,后面不设置死区时间,互补输出正常2.在主程序中每隔一段时间,对死区时间进行设置,设置一个固定的死区时间如245,在设置死区时,输出占空比受影响3.在timer0的update中断中设置死区,输出占空比相同的现象4.在timer0的TIMER_INT_FLAG_CH0中断中设置死区,现象相同分析主要原因是GD32F303的死区设置没有shadow寄存器,导致上面现象,初始化和设置死区程序如下,请各位大神,看看有没有什么好的措施,改善该pwm输出吗?voidtimer0_config(void){/*-----------------------------------------------------------------------TIMER0configuration:generate1complementaryPWMsignal.TIMER0CLKisfixedtosystemcoreclock,theTIMER0prescalerisequalto3sotheTIMER0counterclockusedis40MHz.thedutycycleiscomputedasthefollowingdescription:thechannel0dutycycleissetto25%sochannel0Nissetto75%.insertadeadtimeequalto(120)/systemcoreclock=1usconfigurethebreakfeature,activeathighlevel,andusingtheautomaticoutputenablefeature.usethelockingparameterslevel1.-----------------------------------------------------------------------*/timer_oc_parameter_structtimer_ocintpara;timer_parameter_structtimer_initpara;timer_break_parameter_structtimer_breakpara;rcu_periph_clock_enable(RCU_TIMER0);timer_deinit(TIMER0);/*TIMER0configuration*/timer_initpara.prescaler=0;timer_initpara.alignedmode=TIMER_COUNTER_CENTER_BOTH;//TIMER_COUNTER_EDGE;timer_initpara.counterdirection=TIMER_COUNTER_UP;t
2026-02-09 1

问答