📄 f280x_stepper_pwm.h
字号:
/* ==================================================================================
File name: F280X_STEPPER_PWM.H
Originator: Digital Control Systems Group
Texas Instruments
Description:
Header file containing data type and object definitions and
initializers. Also contains prototypes for the functions in F280XSTEPPRE_PWM.C.
dc-bus+ ------------------------
| |
[1A] [2A]
|----(dc-motor)----|
[1B] [2B]
| |
dc-bus- ------------------------
Target: TMS320F280x family
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20: Using DSP280x v. 1.10 or higher
------------------------------------------------------------------------------------*/
#ifndef __F280X_STEPPER_PWM_H__
#define __F280X_STEPPER_PWM_H__
#include "f280xbmsk.h"
/*----------------------------------------------------------------------------
Initialization constant for the F280X Time-Base Control Registers for PWM Generation.
Sets up the timer to run free upon emulation suspend, count up mode
prescaler 1.
----------------------------------------------------------------------------*/
#define PWM_INIT_STATE ( FREE_RUN_FLAG + \
PHSDIR_CNT_UP + \
CLKDIV_PRESCALE_X_1 + \
HSPCLKDIV_PRESCALE_X_1 + \
PRDLD_IMMEDIATE + \
TIMER_CNT_UPDN + \
CNTLD_DISABLE )
/*----------------------------------------------------------------------------
Initialization constant for the F280X Compare Control Register.
----------------------------------------------------------------------------*/
#define CMPCTL_INIT_STATE ( LOADAMODE_ZRO + \
LOADBMODE_ZRO + \
SHDWAMODE_SHADOW + \
SHDWBMODE_SHADOW )
/*----------------------------------------------------------------------------
Initialization constant for the F280X Action Qualifier Output A Register.
----------------------------------------------------------------------------*/
#define AQCTLA_INIT_STATE ( CAU_SET + CAD_CLEAR )
/*----------------------------------------------------------------------------
Initialization constant for the F280X Dead-Band Generator registers for PWM Generation.
Sets up the dead band for PWM and sets up dead band values.
----------------------------------------------------------------------------*/
#define DBCTL_INIT_STATE (BP_ENABLE + POLSEL_ACTIVE_HI_CMP)
#define DBCNT_INIT_STATE 50 // 50 counts = 1 usec (delay) * 100 count/usec (for TBCLK = SYSCLK/1)
/*----------------------------------------------------------------------------
Initialization constant for the F280X PWM Chopper Control register for PWM Generation.
----------------------------------------------------------------------------*/
#define PCCTL_INIT_STATE CHPEN_DISABLE
/*----------------------------------------------------------------------------
Initialization constant for the F280X Trip Zone Select Register
----------------------------------------------------------------------------*/
#define TZSEL_INIT_STATE DISABLE_TZSEL
/*----------------------------------------------------------------------------
Initialization constant for the F280X Trip Zone Control Register
----------------------------------------------------------------------------*/
#define TZCTL_INIT_STATE ( TZA_HI_Z + TZB_HI_Z + \
DCAEVT1_HI_Z + DCAEVT2_HI_Z + \
DCBEVT1_HI_Z + DCBEVT2_HI_Z )
/*-----------------------------------------------------------------------------
Define the structure of the PWM Driver Object
-----------------------------------------------------------------------------*/
typedef struct {
Uint16 RotationA1; // Input: 0 = PWM1&4 enabled, 1 = PWM2&3 enabled (Q0)
Uint16 RotationB1; // Input: 0 = PWM1&4 enabled, 1 = PWM2&3 enabled (Q0)
Uint16 RotationA2; // Input: 0 = PWM1&4 enabled, 1 = PWM2&3 enabled (Q0)
Uint16 RotationB2; // Input: 0 = PWM1&4 enabled, 1 = PWM2&3 enabled (Q0)
int16 MfuncPeriod; // Input: Period scaler (Q15)
int16 DutyFuncA1; // Input: PWM period modulation input (Q15)
int16 DutyFuncB1; // Input: PWM period modulation input (Q15)
int16 DutyFuncA2; // Input: PWM period modulation input (Q15)
int16 DutyFuncB2; // Input: PWM period modulation input (Q15)
Uint16 PeriodMax; // Parameter: Maximum period (Q0)
Uint16 PwmActive; // Parameter: 0 = PWM active low, 1 = PWM active high (0 or 1)
void (*init)(); // Pointer to the init function
void (*update)(); // Pointer to the update function
} PWMGEN ;
/*
The "PwmActive" setting depends on Power devices.
when PwmActive = 1 (active high) implies the power device turns ON with a HIGH gate signal.
PwmActive = 0 (active low) implies the power device turns ON with a LOW gate signal.
*/
/*-----------------------------------------------------------------------------
Define a PWMGEN_handle
-----------------------------------------------------------------------------*/
typedef PWMGEN *PWMGEN_handle;
/*------------------------------------------------------------------------------
Default Initializers for the F280X PWMGEN Object
------------------------------------------------------------------------------*/
#define F280X_STEPPRE_PWM_GEN {0, 0, 0, 0, \
0x7FFF, \
0x4000, \
0x4000, \
0x4000, \
0x4000, \
1000, \
1, \
(void (*)(Uint32))F280X_STEPPER_PWM_Init, \
(void (*)(Uint32))F280X_STEPPER_PWM_Update \
}
#define PWMGEN_DEFAULTS F280X_STEPPRE_PWM_GEN
/*------------------------------------------------------------------------------
Prototypes for the functions in F280XSTEPPRE_PWM.C
------------------------------------------------------------------------------*/
void F280X_STEPPER_PWM_Init(PWMGEN_handle);
void F280X_STEPPER_PWM_Update(PWMGEN_handle);
#endif // __F280X_STEPPRE_PWM_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -