⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lle_int_handler.cxgate

📁 BCM 控制demo源代码
💻 CXGATE
字号:
/*
***************************************************************************//*!
* 
* @file      int_handler.cxgate
*
* @author    RC574C
* 
* @version   1.0.1.0
* 
* @date      Oct-12-2006
*
* @brief     XGATE RTI handler.
* 
* @note      Compiler CodeWarrior HCS12X V4.1
*
******************************************************************************/

/******************************************************************************
* INCLUDE
******************************************************************************/

/** S12X derivative information */ 
#include <MC9S12XEP100.h> 

/** Common defines and macros */
#include <hidef.h> 
//#include "main.h"
#include "lle_XGATE_PWM.h"
#include "lle_XGATE_PWM_defs.h"
 
/**************************************************************************//*!
*
* @brief   xPWM generator implementation 
*
* @remarks Implementation of xPWM functionality in PIT interrupt handler
*
* @return  None
*
* @note    To use it don't forget to add reference to appropriate int. vector
*          Virtual xPWM uses selected parts of PIT module (see xPWMDEFS.h)
*
******************************************************************************/

void interrupt XGATE_PWM_int(byte PIT_Channel) 
{                                 
    // channel counter
    byte i;  
    
    // Clear interrupt flag      
    PITTF = PIT_Channel;                                   
    i=0;   
    while (i < XPWM_CH_MAX) 
    {        
        // if period is over...
        if(xPWM_ch[i].cnt == 0)                              
        {
           // reload new period information
           xPWM_ch[i].cnt = xPWM_ch[i].period;					 	   
           // to achieve real 100% and 0% duty cycles
           if(xPWM_ch[i].cnt == xPWM_ch[i].duty)             
           {         
               // switch channel on by write a one to corresponding pin
               *xPWM_ch[i].port |= (xPWM_ch[i].port_mask);   
           }
           else 
           {
             // ...switch channel off
             *xPWM_ch[i].port &= ~xPWM_ch[i].port_mask;
           }
        } 
        else 
        {
            // if duty (switch on point) has been reached
            if(xPWM_ch[i].cnt == xPWM_ch[i].duty)
            {              
                // switch channel on by write a one to the corresponding pin     
                *xPWM_ch[i].port |= xPWM_ch[i].port_mask;       
            }
        }
        // decrease counter which represents position within period
        xPWM_ch[i].cnt--;          								  			   
        // increase xPWM channel counter
        i++;
    }
}

/***************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -