打印

F28035这段代码什么意思?求大神解答

[复制链接]
1168|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
446729676|  楼主 | 2016-3-13 15:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
void update_compare(EPWM_INFO *epwm_info)
{
   // Every 10'th interrupt, change the CMPA/CMPB values
   if(epwm_info->EPwmTimerIntCount == 10)
   {
       epwm_info->EPwmTimerIntCount = 0;

       // If we were increasing CMPA, check to see if
       // we reached the max value.  If not, increase CMPA
       // else, change directions and decrease CMPA
           if(epwm_info->EPwm_CMPA_Direction == EPWM_CMP_UP)
           {
               if(epwm_info->EPwmRegHandle->CMPA.half.CMPA < epwm_info->EPwmMaxCMPA)
               {
                  epwm_info->EPwmRegHandle->CMPA.half.CMPA++;
               }
               else
               {
                  epwm_info->EPwm_CMPA_Direction = EPWM_CMP_DOWN;
              epwm_info->EPwmRegHandle->CMPA.half.CMPA--;
               }
           }

           // If we were decreasing CMPA, check to see if
       // we reached the min value.  If not, decrease CMPA
       // else, change directions and increase CMPA
           else
           {
               if(epwm_info->EPwmRegHandle->CMPA.half.CMPA == epwm_info->EPwmMinCMPA)
               {
                  epwm_info->EPwm_CMPA_Direction = EPWM_CMP_UP;
                  epwm_info->EPwmRegHandle->CMPA.half.CMPA++;
               }
               else
               {
                  epwm_info->EPwmRegHandle->CMPA.half.CMPA--;
               }
           }

           // If we were increasing CMPB, check to see if
       // we reached the max value.  If not, increase CMPB
       // else, change directions and decrease CMPB
           if(epwm_info->EPwm_CMPB_Direction == EPWM_CMP_UP)
           {
               if(epwm_info->EPwmRegHandle->CMPB < epwm_info->EPwmMaxCMPB)
               {
                  epwm_info->EPwmRegHandle->CMPB++;
               }
               else
               {
                  epwm_info->EPwm_CMPB_Direction = EPWM_CMP_DOWN;
                  epwm_info->EPwmRegHandle->CMPB--;
               }
           }

           // If we were decreasing CMPB, check to see if
       // we reached the min value.  If not, decrease CMPB
       // else, change directions and increase CMPB

           else
           {
               if(epwm_info->EPwmRegHandle->CMPB == epwm_info->EPwmMinCMPB)
               {
                  epwm_info->EPwm_CMPB_Direction = EPWM_CMP_UP;
                  epwm_info->EPwmRegHandle->CMPB++;
               }
               else
               {
                  epwm_info->EPwmRegHandle->CMPB--;
               }
           }
   }
   else
   {
      epwm_info->EPwmTimerIntCount++;
   }

   return;
}

相关帖子

沙发
zhangmangui| | 2016-3-13 21:19 | 只看该作者
自己对照寄存器边看边注释吧

使用特权

评论回复
板凳
Brand2| | 2016-3-15 16:18 | 只看该作者
这个是不是用来更新比较器的值的

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

3

帖子

0

粉丝