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

[复制链接]
 楼主| 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

粉丝
快速回复 在线客服 返回列表 返回顶部

2

主题

3

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部