|
|
|
Bean
PWMMC
|
Pulse width modulation for motor control
Methods are user callable functions/subroutines that are means of controlling the bean functions.
|
Methods:
-
Enable
- Enable the bean - it starts the signal generation. Events can be disabled/enabled by DisableEvent/EnableEvent.
ANSIC prototype: byte Enable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
Disable
- 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.
ANSIC prototype: byte Disable(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
EnableEvent
- Enable the events. Method is available only if interrupt service/event is enabled.
ANSIC prototype: byte EnableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
DisableEvent
- Disable the events. Method is available only if interrupt service/event is enabled.
ANSIC prototype: byte DisableEvent(void)
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_SPEED - This device does not work in the active speed mode
-
SetPeriod
- Setting PWM modulo register. The value is loaded after calling Load() method.
ANSIC prototype: byte SetPeriod(word period)
- period:word - Value for setting PWM period register in range 15 bit (12-bit on HC08 family).
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_RANGE - Parameter period is out of range
-
SetDuty
- Setting duty(value) register of selected channel. The value is loaded after calling Load() method.
ANSIC prototype: byte SetDuty(byte channel,int duty)
- channel:byte - channel 0-5
- duty:int - Duty value for selected channel. Writing a number less than or equal to 0 causes the PWM to be off for the entire PWM period. Writing a number greater than or equal to the 15 bit (12-bit on HC08MR32 CPU) modulus causes the PWM to be on for the entire PWM period.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_NOTAVAIL - Channel is disabled ERR_RANGE - Parameter channel is out of range
-
SetDutyPercent
- Setting duty(value) in percent of selected channel. The value is loaded after calling Load() method.
ANSIC prototype: byte SetDutyPercent(byte channel,byte duty)
- channel:byte - channel 0-5
- duty:byte - Duty value in percents for selected channel in range 0 .. 100.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_NOTAVAIL - Channel is disabled ERR_RANGE - Parameter channel is out of range
-
SetPrescaler
- Set Prescaler value which is loaded after calling Load() method.
ANSIC prototype: byte SetPrescaler(byte presc)
- presc:byte - Prescaler value in range 0-3.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_RANGE - Parameter out of range
-
Load
- Apply last setting of the methods SetDuty, SetDutyPercent, SetPeriod and SetPrescaler.
ANSIC prototype: void Load(void)
-
SetOutput
- PWM Output control. This method is not available for MC68HC08LB8 CPU type.
ANSIC prototype: byte SetOutput(bool OutCTL,TChannels Outputs)
- OutCTL:bool - If TRUE, output control is set to manual and parameter Outputs has sense.
- Outputs:TChannels - Output pads are set/cleared according to values in Outputs structure.Parameter has sense only if OutCTL is TRUE.
- Return value:byte - Error code, possible codes:
ERR_OK - OK
- Methods only for 56800 and HCS12 derivatives.
-
SetRatio16
- This method sets a new duty-cycle ratio for selected channel.
ANSIC prototype: byte SetRatio16(byte channel,word ratio)
- channel:byte - channel 0 - 5
- ratio:word - Ratio is expressed as an 16-bit unsigned integer number. 0 - 65535 value is proportional to ratio 0 - 100%.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_NOTAVAIL - Channel is disabled ERR_RANGE - Parameter channel is out of range
-
SetRatio15
- This method sets a new duty-cycle ratio for selected channel.
ANSIC prototype: byte SetRatio15(byte channel,int ratio)
- channel:byte - channel 0 - 5
- ratio:int - Ratio is expressed as an 16-bit signed integer number. 0 - 32767 value is proportional to ratio 0 - 100%. Value under 0 corresponds to 0% ratio.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_NOTAVAIL - Channel is disabled ERR_RANGE - Parameter channel is out of range
-
Swap
- Swap channel pairs. Method is available only if hardware acceleration is enabled.
ANSIC prototype: byte Swap(TChannelPairs SwapPair)
- SwapPair:TChannelPairs - Logical 1 swaps channel pair. Logical 0 doesn't swap pair.
- Return value:byte - Error code, possible codes:
ERR_OK - OK
-
ClearFaultFlag
- This method clears fault flag. Method is available only if interrupt service/event is enabled and Fault is set to the manual clearing mode.
ANSIC prototype: byte ClearFaultFlag(byte Flag)
- Flag:byte - Number of the flag.
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_RANGE - Parameter Flag is out of range
Note: Some methods can be implemented as macros.
|
|
|
Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.
|
|
|