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

📄 pwm.h

📁 在ccs编程环境下
💻 H
字号:


#ifndef __F28X_PWM_H__
#define __F28X_PWM_H__

#include "f28xbmsk.h"

/*----------------------------------------------------------------------------
Initialization constant for the F28X Timer TxCON for PWM Generation. 
Sets up the timer to run free upon emulation suspend, continuous up-down mode
prescaler 1, timer enabled.
----------------------------------------------------------------------------*/
#define PWM_INIT_STATE  (FREE_RUN_FLAG +         \
                        TIMER_CONT_UPDN +        \
                        TIMER_CLK_PRESCALE_X_1 + \
                        TIMER_ENABLE_BY_OWN    + \
                        TIMER_ENABLE)

/*----------------------------------------------------------------------------
Initialization constant for the F28X ACTRx register for PWM Generation. 
Sets up PWM polarities.
----------------------------------------------------------------------------*/
#define ACTR_INIT_STATE ( COMPARE1_AH + \
                          COMPARE2_AL + \
                          COMPARE3_AH + \
                          COMPARE4_AL + \
                          COMPARE5_AH + \
                          COMPARE6_AL )

/*----------------------------------------------------------------------------
Initialization constant for the F28X DBTCONx register for PWM Generation. 
Sets up the dead band for PWM and sets up dead band values.
----------------------------------------------------------------------------*/
#define DBTCON_INIT_STATE ( DBT_VAL_13 +  \
                            EDBT3_EN   +  \
                            EDBT2_EN   +  \
                            EDBT1_EN   +  \
                            DBTPS_X32 )

/*-----------------------------------------------------------------------------
Define the structure of the PWM Driver Object 
-----------------------------------------------------------------------------*/
typedef struct {   
        int n_period;       /* Input: PWM Half-Period in CPU clock cycles (Q0)  */
        int Mfunc_p;           /* Input: Period scaler (Q15)                */
        int Mfunc_c1;          /* Input: PWM 1&2 Duty cycle ratio (Q15)       */
        int Mfunc_c2;          /* Input: PWM 3&4 Duty cycle ratio (Q15)       */
        int Mfunc_c3;          /* Input: PWM 5&6 Duty cycle ratio (Q15)       */
        _iq	IA;		/* Input: Phase A current for deadband compensation */
        _iq	IB;		/* Input: Phase B current for deadband compensation */
        _iq	IC;		/* Input: Phase C current for deadband compensation */
        int CMPR1_TEMP;		/* Parameter: Buffer of CMPR1 for deadband compensation */
        int CMPR2_TEMP;		/* Parameter: Buffer of CMPR2 for deadband compensation */
        int CMPR3_TEMP;		/* Parameter: Buffer of CMPR3 for deadband compensation */
        int DB_COM;		/* Input: Deadband compensation */
        long lyh_scope1;
        long lyh_scope2;
/*		Uint32 tmp;*/
        void (*init)();        /* Pointer to the init function               */
        void (*update)();      /* Pointer to the update function             */
        } PWMGEN ;    

/*-----------------------------------------------------------------------------
Define a PWMGEN_handle
-----------------------------------------------------------------------------*/
typedef PWMGEN *PWMGEN_handle;

/*------------------------------------------------------------------------------
Default Initializers for the F28X PWMGEN Object 
------------------------------------------------------------------------------*/
#define F28X_EV1_FC_PWM_GEN {1000,   \
                              0x7FFF, \
                              0x4000, \
                              0x4000, \
                              0x4000, \
                              0,0,0,\
                              0x00,\
                              0x00,\
                              0x00,\
                              0x00,\
                              0x00,\
                              0x00,\
                             (void (*)(long))PWM_Init,  \
                             (void (*)(long))PWM_Update \
                             }

#define F28X_EV2_FC_PWM_GEN {1000,   \
                              0x7FFF, \
                              0x4000, \
                              0x4000, \
                              0x4000, \
                              0x00,\
                              0x00,\
                             (void (*)(long))F28X_EV2_PWM_Init,  \
                             (void (*)(long))F28X_EV2_PWM_Update \
                             }

#define PWMGEN_DEFAULTS 	F28X_EV1_FC_PWM_GEN
/*------------------------------------------------------------------------------
 Prototypes for the functions in F28XPWM.C
------------------------------------------------------------------------------*/
void PWM_Init(PWMGEN_handle);
void PWM_Update(PWMGEN_handle);

#endif  /*__F28X_PWM_H__*/

⌨️ 快捷键说明

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