📄 pwmc1.c
字号:
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : PWMC1.C
** Project : vvvf_56F8346
** Processor : 56F8346
** Beantype : PWMMC
** Version : Bean 01.402, Driver 01.23, CPU db: 2.87.097
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2008-3-7, 9:38
** 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
** ----------------------------------------------------
** 34 | PWMB0
** 35 | PWMB1
** 36 | PWMB2
** 39 | PWMB3
** 40 | PWMB4
** 41 | PWMB5
** ----------------------------------------------------
**
** Device : PWM_B [15-bit]
**
** Counter : PWMB_PMCNT [61796]
** Mode register : PWMB_PMCFG [61807]
** Run register : PWMB_PMCTL [61792]
** Prescaler : PWMB_PMCTL [61792]
** Modulo register : PWMB_PWMCM [61797]
** Compare 0 register : PWMB_PWMVAL0 [61798]
** Compare 1 register : PWMB_PWMVAL1 [61799]
** Compare 2 register : PWMB_PWMVAL2 [61800]
** Compare 3 register : PWMB_PWMVAL3 [61801]
** Compare 4 register : PWMB_PWMVAL4 [61802]
** Compare 5 register : PWMB_PWMVAL5 [61803]
** Fault Control register : PWMB_PMFCTL [61793]
** Fault Status register : PWMB_PMFSA [61794]
** Fault Acknowledge register : PWMB_PMFSA [61794]
** Output Control register : PWMB_PMOUT [61795]
** Dead-Time register : PWMB_PMDEADTM [61804]
** Disable Mapping register 1 : PWMB_PMDISMAP1 [61805]
** Disable Mapping register 2 : PWMB_PMDISMAP2 [61806]
** Channel Control register : PWMB_PMCCR [61808]
** Port register : PWMB_PMPORT [61809]
** Internal Corr. Control reg. : PWMB_PMICCR [61810]
**
** Interrupt name : INT_PWMB_Reload
** Interrupt enable reg. : PWMB_PMCTL [61792]
** Priority : 1
** User handling procedure : PWMC1_OnReload
** This event is called every 1 PWM cycle
**
** Interrupt name : INT_PWMB_Fault
** Interrupt enable reg. : PWMB_PMFCTL [61793]
** Priority : 1
** User handling procedure : PWMC1_OnFault0
** This event is called when fault 0 occurs
** Interrupt name : INT_PWMB_Fault
** Interrupt enable reg. : PWMB_PMFCTL [61793]
** Priority : 1
** User handling procedure : PWMC1_OnFault1
** This event is called when fault 1 occurs
** Interrupt name : INT_PWMB_Fault
** Interrupt enable reg. : PWMB_PMFCTL [61793]
** Priority : 1
** User handling procedure : PWMC1_OnFault2
** This event is called when fault 2 occurs
** Interrupt name : INT_PWMB_Fault
** Interrupt enable reg. : PWMB_PMFCTL [61793]
** Priority : 1
** User handling procedure : PWMC1_OnFault3
** This event is called when fault 3 occurs
**
** 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 : positive
** Top-side PWM pair 1 polarity : positive
** Top-side PWM pair 2 polarity : positive
** 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 : Enabled
** Enable in Wait mode : no
** Enable in EnOnCE mode : no
** Reload : every 1 PWM cycle
** Half cycle reload : no
** Hardware acceleration : disabled
**
** Dead Time
** High speed mode
** Prescaler : divide-by-180
** Clock : 333333 Hz
** Xtal ticks : 24
** microseconds : 3
** seconds (real) : 0.0000030
**
** 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
**
** Fault device 1
** clearing mode : automatic
** pin : FAULTB0
** Fault device 2
** clearing mode : automatic
** pin : FAULTB1
** Fault device 3
** clearing mode : automatic
** pin : FAULTB2
** Fault device 4
** clearing mode : automatic
** pin : FAULTB3
**
** 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 : 60000000 Hz
** Unit Xtal ticks
** Period : 500
** Channel 0 pulse width : 250
** Channel 1 pulse width : 250
** Channel 2 pulse width : 250
** Channel 3 pulse width : 250
** Channel 4 pulse width : 250
** Channel 5 pulse width : 250
** Unit microseconds
** Period : 62
** Channel 0 pulse width : 31
** Channel 1 pulse width : 31
** Channel 2 pulse width : 31
** Channel 3 pulse width : 31
** Channel 4 pulse width : 31
** Channel 5 pulse width : 31
** Unit seconds (real)
** Period : 0.0000625
** Channel 0 pulse width : 0.0000313
** Channel 1 pulse width : 0.0000313
** Channel 2 pulse width : 0.0000313
** Channel 3 pulse width : 0.0000313
** Channel 4 pulse width : 0.0000313
** Channel 5 pulse width : 0.0000313
**
** Contents :
** Enable - byte PWMC1_Enable(void);
** Disable - byte PWMC1_Disable(void);
** SetDuty - byte PWMC1_SetDuty(byte channel,int duty);
** Load - void PWMC1_Load(void);
** SetRatio15 - byte PWMC1_SetRatio15(byte channel,int ratio);
** OutputPadEnable - void PWMC1_OutputPadEnable(void);
** OutputPadDisable - void PWMC1_OutputPadDisable(void);
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE PWMC1. */
#include "Events.h"
#include "PWMC1.h"
static bool EnUser; /* Enable/Disable device by user */
/*
** ===================================================================
** Method : PWMC1_HWEnDi (bean PWMMC)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void HWEnDi(void)
{
if (EnUser) { /* Enable device? */
setRegBits(PWMB_PMCTL,3); /* Load counter and modulo registers into buffers and run counter */
}
else { /* Disable device? */
clrRegBit(PWMB_PMCTL,PWMEN); /* Stop counter */
}
}
/*
** ===================================================================
** Method : PWMC1_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 PWMC1_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 : PWMC1_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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -