📄 pwm.h
字号:
/******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2001 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* FILE NAME: pwm.h
*
* DESCRIPTION: Header file for PWM driver
*
* MODULES INCLUDED: pwmtarget.h
*
* NOTES:
*
*******************************************************************************/
#ifndef __PWM_H
#define __PWM_H
/******************************************************************************
*
* General Interface Description
*
* The Pulse Width Modulator (PWM) modules incorporate three complementary, individually
* programmable PWM signal outputs. The DSP56801 and DSP56803 contain one PWM module (PWM A)
* while DSP56805 and DSP56807 have two PWM modules (PWM A and PWM B).
* Each module is also capable of supporting six independent PWM functions
* to enhance motor control functionality.
* Complementary operation permits programmable dead-time insertion,
* distortion correction via current sensing by software, and separate top and bottom output
* polarity control. The up-counter value is programmable to support a continuously variable
* PWM frequency. Both edge- and center-aligned synchronous pulse width control (full 0%
* to 100% modulation) are supported.
*
* The device is capable of controlling most motor types:
* ACIM (AC Induction Motors)
* BDC and BLDC (Brush and Brushless DC motors)
* SRM and VRM (Switched and Variable Reluctance Motors)
* Stepper motors
*
* The PWMs incorporate fault protection and cycle-by-cycle current limiting with sufficient
* output drive capability to directly drive standard opto-isolators.
* Note, The DSP56801 PWM has 1 Fault Pin, the DSP56803 has 3 Fault Pins,
* the DSP56805 and DSP56807 have 4 Fault Pins.
* Write-once protection feature for key parameters is also included. A patented PWM
* waveform distortion correction circuit is also provided. Each PWM is double-buffered and
* includes interrupt controls to permit integral reload rates to be programmable from 1 to 16.
* The PWM modules also provide a reference output to synchronize the Analog-to-Digital
* Converters.
*
* For more information, please refer to the User Manual for the particular chip that you
* are using, such as the DSP56F801/803/805/807 User's Manual, for a description
* of the PWM device.
*
* The PWM device driver interface uses "ioctl" call to control specific PWM functions
* during operation. For details see "ioctl" call.
*
******************************************************************************/
/************************************************************
* PWM module identifiers, correspond to module base address
*************************************************************/
#define PWM_A (&ArchIO.PwmA)
#define PWM_B (&ArchIO.PwmB) /* not applicable for DSP56801/803 */
/****************************************************
* Configurable items, i.e. defines, for appconfig.h
*****************************************************
void pwmxxISR( void ); prototype for user ISR
#define INTERRUPT_VECTOR_ADDR_yy pwmxxISR
#define ITCN_INT_PRIORITY_yy value 0-7 (0 = interrupt disabled)
#define PWM_x_CONTROL_REG 0x0000
#define PWM_x_FAULT_CONTROL_REG 0x0000
#define PWM_x_FAULT_STATUS_REG 0x0000
#define PWM_x_OUTPUT_CONTROL_REG 0x0000
#define PWM_x_COUNTER_MODULO_REG 0x0000
#define PWM_x_DEAD_TIME_REG 0x0000
#define PWM_x_DISABLE_MAPPING_1_REG 0x0000
#define PWM_x_DISABLE_MAPPING_2_REG 0x0000
#define PWM_x_CONFIG_REG 0x0000
#define PWM_x_CHANNEL_CONTROL_REG 0x0000
where:
x is PWM module (A or B)
yy is interrupt vector number
61 - PWM A Fault
60 - PWM B Fault
59 - PWM A Reload
58 - PWM B Reload
*/
/*****************************************************************
* ioctl() commands
*
* Word16 ioctl( PWM_module_identifier, Command_name, Parameter );
*
******************************************************************
COMMAND NAME PARAMETERS, COMMENTS
------------------------------------------------------------------ */
#define PWM_INIT /* NULL */
#define PWM_SET_RELOAD_FREQUENCY /* PWM_RELOAD_OPPORTUNITY_X */
#define PWM_HALF_CYCLE_RELOAD /* PWM_ENABLE | PWM_DISABLE */
#define PWM_SET_CURRENT_POLARITY /* (PWM_IPOL_0 | PWM_IPOL_1 | PWM_IPOL_2) / PWM_ZERO_MASK */
#define PWM_SET_PRESCALER /* PWM_PRESCALER_DIV_X */
#define PWM_RELOAD_INT /* PWM_ENABLE | PWM_DISABLE */
#define PWM_SET_CURRENT_SENSING /* PWM_CORRECTION_XX */
#define PWM_DEVICE /* PWM_ENABLE | PWM_DISABLE */
#define PWM_CLEAR_RELOAD_FLAG /* NULL */
#define PWM_LOAD_OK /* NULL */
#define PWM_FAULT_INT_ENABLE /* PWM_FAULT_x */
#define PWM_FAULT_INT_DISABLE /* PWM_FAULT_x */
#define PWM_SET_AUTOMATIC_FAULT_CLEAR /* PWM_FAULT_x */
#define PWM_SET_MANUAL_FAULT_CLEAR /* PWM_FAULT_x */
#define PWM_CLEAR_FAULT_FLAG /* PWM_FAULT_x */
#define PWM_OUTPUT_PAD /* PWM_ENABLE | PWM_DISABLE */
#define PWM_OUTPUT_SOFTWARE_CONTROL /* mc_tPWMSignalMask */
#define PWM_OUTPUT_CONTROL /* mc_tPWMSignalMask */
#define PWM_SET_MODULO /* value */
#define PWM_GET_MODULO /* NULL */
#define PWM_SET_DEADTIME /* value */
#define PWM_WRITE_DISABLE_MAPPING_REG1 /* value */
#define PWM_WRITE_DISABLE_MAPPING_REG2 /* value */
#define PWM_SET_ALIGNMENT /* (PWM_ALIGN_EDGE | PWM_ALIGN_CENTER) */
#define PWM_SET_NEG_TOP_SIDE_POLARITY /* (PWM_CHANNEL_45 | PWM_CHANNEL_23 | PWM_CHANNEL_01) / PWM_ZERO_MASK */
#define PWM_SET_NEG_BOTTOM_SIDE_POLARITY /* (PWM_CHANNEL_45 | PWM_CHANNEL_23 | PWM_CHANNEL_01) / PWM_ZERO_MASK */
#define PWM_SET_INDEPENDENT_OPERATION /* (PWM_CHANNEL_45 | PWM_CHANNEL_23 | PWM_CHANNEL_01) / PWM_ZERO_MASK */
#define PWM_SET_WRITE_PROTECT /* NULL */
#define PWM_HARDWARE_ACCELERATION /* PWM_ENABLE | PWM_DISABLE */
#define PWM_SET_CHANNEL_MASK /* mc_tPWMSignalMask */
#define PWM_SET_LOAD_MODE /* PWM_LOAD_xx */
#define PWM_SET_SWAP /* (PWM_CHANNEL_45 | PWM_CHANNEL_23 | PWM_CHANNEL_01) / PWM_ZERO_MASK */
#define PWM_WRITE_VALUE_REG_0 /* value */
#define PWM_WRITE_VALUE_REG_1 /* value */
#define PWM_WRITE_VALUE_REG_2 /* value */
#define PWM_WRITE_VALUE_REG_3 /* value */
#define PWM_WRITE_VALUE_REG_4 /* value */
#define PWM_WRITE_VALUE_REG_5 /* value */
#define PWM_WRITE_VALUE_REGS_COMPL /* pwm_sComplementaryValues* */
#define PWM_WRITE_VALUE_REGS_INDEP /* pwm_sIndependentValues* */
#define PWM_READ_FAULT_STATUS_REG /* NULL */
#define PWM_READ_COUNTER_REG /* NULL */
#define PWM_READ_CONTROL_REG /* NULL */
#define PWM_READ_PORT_REG /* NULL */
#define PWM_SOFTWARE_OUTPUTS_CONTROL /* pwm_sOutputControl* */
#define PWM_UPDATE_VALUE_REG_0 /* value */
#define PWM_UPDATE_VALUE_REG_1 /* value */
#define PWM_UPDATE_VALUE_REG_2 /* value */
#define PWM_UPDATE_VALUE_REG_3 /* value */
#define PWM_UPDATE_VALUE_REG_4 /* value */
#define PWM_UPDATE_VALUE_REG_5 /* value */
#define PWM_UPDATE_VALUE_REGS_COMPL /* pwm_sComplementaryValues* */
#define PWM_UPDATE_VALUE_REGS_INDEP /* pwm_sIndependentValues* */
#define PWM_UPDATE_VALUE_SET_VLMODE /* pwm_sUpdateValueSetVlmode* */
#define PWM_CORRECT_DEAD_TIME_COMPL /* pwm_sComplementaryValues* */
#define PWM_SET_MASK_SWAP /* pwm_sChannelControl* */
/****************************************************************************
* PWM constants and type declarations use in the ioctl functions
*****************************************************************************/
#define PWM_ZERO_MASK 0x0000
#define PWM_IPOL_0 0x0400 /* Current Polarity Bit 0 */
#define PWM_IPOL_1 0x0200 /* Current Polarity Bit 1 */
#define PWM_IPOL_2 0x0100 /* Current Polarity Bit 2 */
#define PWM_RELOAD_OPPORTUNITY_1 0
#define PWM_RELOAD_OPPORTUNITY_2 1
#define PWM_RELOAD_OPPORTUNITY_3 2
#define PWM_RELOAD_OPPORTUNITY_4 3
#define PWM_RELOAD_OPPORTUNITY_5 4
#define PWM_RELOAD_OPPORTUNITY_6 5
#define PWM_RELOAD_OPPORTUNITY_7 6
#define PWM_RELOAD_OPPORTUNITY_8 7
#define PWM_RELOAD_OPPORTUNITY_9 8
#define PWM_RELOAD_OPPORTUNITY_10 9
#define PWM_RELOAD_OPPORTUNITY_11 10
#define PWM_RELOAD_OPPORTUNITY_12 11
#define PWM_RELOAD_OPPORTUNITY_13 12
#define PWM_RELOAD_OPPORTUNITY_14 13
#define PWM_RELOAD_OPPORTUNITY_15 14
#define PWM_RELOAD_OPPORTUNITY_16 15
#define PWM_PRESCALER_DIV_1 0
#define PWM_PRESCALER_DIV_2 1
#define PWM_PRESCALER_DIV_4 2
#define PWM_PRESCALER_DIV_8 3
#define PWM_CORRECTION_NO 0
#define PWM_CORRECTION_SOFTWARE 1
#define PWM_CORRECTION_DURING_DEADTIME 2 /* not applicable for DSP56801 */
#define PWM_CORRECTION_DURING_CYCLE 3 /* not applicable for DSP56801 */
#define PWM_FAULT_0 0
#define PWM_FAULT_1 1 /* not applicable for DSP56801 */
#define PWM_FAULT_2 2 /* not applicable for DSP56801 */
#define PWM_FAULT_3 3 /* not applicable for DSP56801/803 */
#define PWM_ENABLE true
#define PWM_DISABLE false
#define PWM_ALIGN_EDGE true
#define PWM_ALIGN_CENTER false
#define PWM_CHANNEL_45 0x0004
#define PWM_CHANNEL_23 0x0002
#define PWM_CHANNEL_01 0x0001
#define PWM_LOAD_INDEP 0
#define PWM_LOAD_FROM_0_TO_5 1
#define PWM_LOAD_FROM_0_TO_3 2
#define PWM_COMPLEMENTARY_MODE 0
#define PWM_INDEPENDENT_MODE 1
/****************************************************************************/
typedef UWord16 pwm_tPWMChannelSwap; /* pwm_tPWMChannelSwap contains three control bits
representing channel swapping of PWM signals.
The bits can be combined in a numerical value
that represents the union of the appropriate
bits. For example, the value 0x05 indicates
that PWM channel 0 and 1 are swapped, channel 4 and 5 are swapped.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -