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

📄 pwm.c

📁 用freescale公司的DSP56F8013芯片实现的PMSM的SVPWM 驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : PWM.C
**     Project   : PMSM
**     Processor : 56F8013VFAE
**     Beantype  : PWMMC
**     Version   : Bean 01.491, Driver 01.27, CPU db: 2.87.089
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2008-1-24, 下午 01:45
**     Abstract  :
**         This bean "PWMMC" implements 6-channel center-aligned or 
**         edge-aligned pulse-width modulator for AC motor control, which 
**         is presented on chip. The device is capable of controlling most 
**         motor types: AC induction motors (ACIM), both brushless (BLDC) 
**         and brush DC motors (BDC), switched (SRM) and variable reluctance  
**         motors (VRM),and stepper motors.
**         Another possibility of using this bean is as a pulse-width modulation 
**         generator that generates 6 signals with variable duty and fixed cycle.
**     Settings  :
**         Used output pins            :
**             ----------------------------------------------------
**                Number (on package)  |    Name
**             ----------------------------------------------------
**                       29            |  GPIOA0_PWM0
**                       28            |  GPIOA1_PWM1
**                       23            |  GPIOA2_PWM2
**                       24            |  GPIOA3_PWM3
**                       22            |  GPIOA4_PWM4_FAULT1_T2
**                       20            |  GPIOA5_PWM5_FAULT2_T3
**             ----------------------------------------------------
**
**         Device                      : PWM_Timer [15-bit]
**
**         Counter                     : PWM_PMCNT [61508]
**         Mode register               : PWM_PMCFG [61520]
**         Run register                : PWM_PMCTL [61504]
**         Prescaler                   : PWM_PMCTL [61504]
**         Modulo register             : PWM_PWMCM [61509]
**         Compare 0 register          : PWM_PWMVAL0 [61510]
**         Compare 1 register          : PWM_PWMVAL1 [61511]
**         Compare 2 register          : PWM_PWMVAL2 [61512]
**         Compare 3 register          : PWM_PWMVAL3 [61513]
**         Compare 4 register          : PWM_PWMVAL4 [61514]
**         Compare 5 register          : PWM_PWMVAL5 [61515]
**         Fault Control register      : PWM_PMFCTL [61505]
**         Fault Status register       : PWM_PMFSA [61506]
**         Fault Acknowledge register  : PWM_PMFSA [61506]
**         Output Control register     : PWM_PMOUT [61507]
**         Dead-Time register          : PWM_PMDEADTM0 [61516]
**         Dead-Time 1 register        : PWM_PMDEADTM1 [61517]
**         Disable Mapping register  1 : PWM_PMDISMAP1 [61518]
**         Disable Mapping register  2 : PWM_PMDISMAP2 [61519]
**         Channel Control register    : PWM_PMCCR [61521]
**         Port register               : PWM_PMPORT [61522]
**         Internal Corr. Control reg. : PWM_PMICCR [61523]
**         PWM Source Control register : PWM_PMSRC [61524]
**
**         Interrupt name              : INT_PWM_Reload
**         Interrupt enable reg.       : PWM_PMCTL [61504]
**         Priority                    : 1
**         User handling procedure     : PWM_OnReload
**         This event is called every 1 PWM cycle
**
**
**     Initialization:
**          Align                      : center-aligned mode
**          Mode of PWM pair 0         : complementary
**          Mode of PWM pair 1         : complementary
**          Mode of PWM pair 2         : complementary
**          Top-side PWM pair 0 polarity : negative
**          Top-side PWM pair 1 polarity : negative
**          Top-side PWM pair 2 polarity : negative
**          Bottom-side PWM pair 0 polarity : negative
**          Bottom-side PWM pair 1 polarity : negative
**          Bottom-side PWM pair 2 polarity : negative
**          Write protect              : no
**          Output                     : Disabled
**          Enable in Wait mode        : no
**          Enable in EnOnCE mode      : no
**          Reload                     : every 1 PWM cycle
**          Half cycle reload          : yes
**          Hardware acceleration      : enabled
**          Load Mode                  : mode 1
**          Improved Swap and Mask     : Enhanced
**          Swap channel 0 and 1       : no
**          Swap channel 2 and 3       : no
**          Swap channel 4 and 5       : no
**
**          Dead Time
**          High speed mode
**              Prescaler              : divide-by-32
**              Clock                  : 1000000 Hz
**              Xtal ticks             : 8
**              microseconds           : 1
**              seconds (real)         : 0.0000010
**
** Output control channel 0            : Disabled
** Output control channel 1            : Disabled
** Output control channel 2            : Disabled
** Output control channel 3            : Disabled
** Output control channel 4            : Disabled
** Output control channel 5            : Disabled
**
** Correction
**   Correction method                 : method 1
**   PWM pair 0                        : top
**   PWM pair 1                        : top
**   PWM pair 2                        : top
**
**   Channel masks
**     Mask channel 0                  : no
**     Mask channel 1                  : no
**     Mask channel 2                  : no
**     Mask channel 3                  : no
**     Mask channel 4                  : no
**     Mask channel 5                  : no
**
**
** Mask fault pins
** Channel 0
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
** Channel 1
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
** Channel 2
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
** Channel 3
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
** Channel 4
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
** Channel 5
**   Mask fault 1                      : yes
**   Mask fault 2                      : yes
**   Mask fault 3                      : yes
**   Mask fault 4                      : yes
**
**  Device                             : Enabled
**  Event                              : Enabled
**  High speed mode
**    Prescaler                        : divide-by-1
**    Clock                            : 32000000 Hz
**    Unit                              Xtal ticks
**      Period                         : 400
**      Channel 0 pulse width          : 200
**      Channel 1 pulse width          : 200
**      Channel 2 pulse width          : 200
**      Channel 3 pulse width          : 200
**      Channel 4 pulse width          : 200
**      Channel 5 pulse width          : 200
**    Unit                              microseconds
**      Period                         : 50
**      Channel 0 pulse width          : 25
**      Channel 1 pulse width          : 25
**      Channel 2 pulse width          : 25
**      Channel 3 pulse width          : 25
**      Channel 4 pulse width          : 25
**      Channel 5 pulse width          : 25
**    Unit                              seconds (real)
**      Period                         : 0.0000500
**      Channel 0 pulse width          : 0.0000250
**      Channel 1 pulse width          : 0.0000250
**      Channel 2 pulse width          : 0.0000250
**      Channel 3 pulse width          : 0.0000250
**      Channel 4 pulse width          : 0.0000250
**      Channel 5 pulse width          : 0.0000250
**
**     Contents  :
**         Enable           - byte PWM_Enable(void);
**         Disable          - byte PWM_Disable(void);
**         EnableEvent      - byte PWM_EnableEvent(void);
**         DisableEvent     - byte PWM_DisableEvent(void);
**         SetPeriod        - byte PWM_SetPeriod(word period);
**         SetDuty          - byte PWM_SetDuty(byte channel,int duty);
**         SetDutyPercent   - byte PWM_SetDutyPercent(byte channel,byte duty);
**         Load             - void PWM_Load(void);
**         OutputPadEnable  - void PWM_OutputPadEnable(void);
**         OutputPadDisable - void PWM_OutputPadDisable(void);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2006
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/


/* MODULE PWM. */

#include "Events.h"
#include "PWM.h"

static bool EnUser;                    /* Enable/Disable device by user */
static bool EnEvent;                   /* Enable/Disable events */

/*
** ===================================================================
**     Method      :  PWM_HWEnDi (bean PWMMC)
**
**     Description :
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void HWEnDi(void)
{
  if (EnUser) {                        /* Enable device? */
    setRegBits(PWM_PMFCTL,0);          /* Enable fault interrupts */
    setRegBits(PWM_PMCTL,35);          /* Load counter and modulo registers into buffers, run counter and enable reload interupt*/
  }
  else {                               /* Disable device? */
    clrRegBits(PWM_PMCTL,33);          /* Stop counter and disable reload interupt*/
    clrRegBits(PWM_PMFCTL,170);        /* Disable fault interrupts */
  }
}
/*
** ===================================================================
**     Method      :  PWM_Enable (bean PWMMC)
**
**     Description :
**         Enable the bean - it starts the signal generation. Events
**         can be disabled/enabled by DisableEvent/EnableEvent.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte PWM_Enable(void)
{
  if (!EnUser) {                       /* Is the device disabled by user? */
    EnUser = TRUE;                     /* If yes then set the flag "device enabled" */
    HWEnDi();                          /* Enable the device */
  }
  return ERR_OK;                       /* OK */
}

/*
** ===================================================================
**     Method      :  PWM_Disable (bean PWMMC)
**
**     Description :
**         Disable the bean - it stops signal generation and events
**         calling. When the timer is disabled, it is possible to
**         call method "SetOutput" to control the output value on
**         corresponding pin.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte PWM_Disable(void)
{
  if (EnUser) {                        /* Is the device enabled by user? */
    EnUser = FALSE;                    /* If yes then set the flag "device disabled" */
    HWEnDi();                          /* Disable the device */
  }
  return ERR_OK;                       /* OK */
}

/*
** ===================================================================
**     Method      :  PWM_EnableEvent (bean PWMMC)
**
**     Description :
**         Enable the events. Method is available only if interrupt
**         service/event is enabled.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte PWM_EnableEvent(void)

⌨️ 快捷键说明

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