问答

汇集网友智慧,解决技术难题

通讯不上

TA的家园币:69  

  • 定时器捕获用DMA运输时的状态位问题

    国民新民G455系列。定时器捕获同时用DMA读取捕获的值,那么在DMA传输过程中,定时器的状态寄存器(STS)里的事件捕获标志是1还是0呢

  • N32G455定时器捕获偶尔会丢一个沿的问题

    本帖最后由通讯不上于2024-2-2114:02编辑使用定时器一个通道捕获频率时偶尔出现频率只有一半的问题。检查重复捕获标志位没有异常。信号源和电路应该没有问题,用pwm模式捕获的话是正常的,求助!!!部分代码:voidinlinepwm_compute(uint8_tidx){//uint32_tfirst_val=0;uint16_tcap_val=0u;//进来先读值uint8_ti=0;//避免在处理这个中断时update没来得及处理导致计算不准确switch(idx){case0:cap_val=TIM_GetCap1(TIM5);break;case1:cap_val=TIM_GetCap2(TIM5);break;case2:cap_val=TIM_GetCap3(TIM5);break;case3:cap_val=TIM_GetCap4(TIM5);break;default:break;}if(ic_info.ic_capnum==0){/*GettheInputCapturevalue*/ic_info.ic_freq_delval=cap_val;//TIM_ConfigOc1Polarity(TIM5,TIM_IC_POLARITY_FALLING);ic_info.ic_capnum=2;//1是有占空比ic_info.ic_overcnt=0;}elseif(ic_info.ic_capnum==1){/*GettheInputCapturevalue*/ic_info.ic_duty_delval=ic_info.ic_overcnt*65535+cap_val-ic_info.ic_freq_delval;TIM_ConfigOc1Polarity(TIM5,TIM_IC_POLARITY_RISING);ic_info.ic_capnum=2;}elseif(ic_info.ic_capnum==2){/*GettheInputCapturevalue*///first_val=ic_info.ic_freq_delval;if(cap_val<ic_info.ic_freq_delval&&ic_info.ic_overcnt==0){i=1;}ic_info.ic_freq_delval=(ic_info.ic_overcnt+i)*65535+cap_val-ic_info.ic_freq_delval;//dev_printf("del1=%d",ic_info.ic_freq_delval);//TIM_ConfigOc1Polarity(TIM5,TIM_IC_POLARITY_RISING);ic_info.ic_freq=(uint32_t)(18000000*1.0/ic_info.ic_freq_delval+0.5);ic_info.ic_duty=(uint32_t)((float)ic_info.ic_duty_delval*1.0/ic_info.ic_freq_delval)*1000;//ic_info.ic_capnum=0;if(ic_info.ic_freq<480){dev_printf("freq=%d\n",ic_info.ic_freq);//first_val=0;}//全波形测量ic_info.ic_freq_delval=cap_val;ic_info.ic_overcnt=0;}voidPI_IRQHandler