|
|
|
Component
PWMMC
Pulse width modulation for motor control
Methods:
(Methods are user-callable functions/subroutines intended for
the component functions control. Please see the Embedded Components page for more information.)
-
Enable
- Enable the component - 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 component - it stops signal generation and events calling. When the timer is disabled, it is still 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. The 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. The 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.
Period is valid for actual speed mode only, initial value is restored after speed mode change.
-
SetDuty
- Setting duty (value) register(s) of selected channel. The value is loaded after calling Load method.
Version specific information for Freescale 56800/E and HC08 and HCS12 and HCS12X derivatives
Setting is valid for actual speed mode only, initial value is restored after speed mode change.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
In center-align mode it is necessary to set both odd and event duty registers separatelly.
Duty register(s) value is not affected during speed mode change. It should be handled by the user code.
ANSIC prototype: byte SetDuty(byte Channel, ComponentName_TPWMMC_Duty Duty)
- Channel:byte - Channel number (0 - 5). The number corresponds to the logical channel number assigned in the component settings, which may not correspond to channel number of the peripheral.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives - FTM peripheral
- edge-aligned mode: only odd channel may me modified;
- center-aligned mode: both channels may be modified;
- Duty:ComponentName_TPWMMC_Duty - 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.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives - FTM peripheral:
Parameter duty is an unsigned value.
- edge-aligned mode: parameter value is written into odd channel register; even channel register is not affected (zero value assumed);
- center-aligned mode: parameter value is directly written into compare register
- 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.
Version specific information for Freescale 56800/E and HC08 and HCS12 and HCS12X derivatives
Setting is valid for actual speed mode only, initial value is restored after speed mode change.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
Settings is not affected during speed mode change. It should be handled by the user code.
-
SetPrescaler
- Set prescaler value which is loaded after calling Load method.
Setting is valid for actual speed mode only, initial value is restored after speed mode change.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
On FTM peripheral on HCS08 and ColdFireV1 derivatives, the value SetPrescaler is applied immediately and it is not affected by Load method.
ANSIC prototype: byte SetPrescaler(byte Presc)
- Presc:byte - Prescaler control value, range depends on the selected peripheral.
- 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, both SetRatio*, SetPeriod and SetPrescaler.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
On FTM peripheral on HCS08 and ColdFireV1 derivatives, SetPrescaler is applied immediately and it is not affected by this method.
ANSIC prototype: void Load(void)
-
SetOutput
- PWM Output control. The method is not supported for MC68HC908LB8 derivative.
ANSIC prototype: byte SetOutput(bool OutCTL, TChannels Outputs)
- OutCTL:bool - If true, output control is set to manual (channels' outputs are controled by software, resp. by parameter Outputs) and parameter Outputs has sense. If false, PWM takes control of the channels' outputs (could be used for switch off output control).
- 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
- Method(s) not supported for Freescale HC08 derivatives.
-
SetRatio16
- This method sets a new duty-cycle ratio for selected channel. The value is loaded after calling Load method.
Version specific information for Freescale 56800/E and HC08 and HCS12 and HCS12X derivatives
Setting is valid for actual speed mode only, initial value is restored after speed mode change.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
Settings is not affected during speed mode change. It should be handled by the user code.
ANSIC prototype: byte SetRatio16(byte Channel, word Ratio)
- Channel:byte - channel number (0 - 5). The number corresponds to the logical channel number assigned in the component settings, which may not correspond to channel number of the peripheral.
- Ratio:word - Ratio is expressed as an 16-bit unsigned integer number. 0 - 65535 value is proportional to ratio 0 - 100%.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives - FTM peripheral:
- edge-aligned mode: parameter value is written into odd channel register; even channel register is not affected (zero value assumed);
- center-aligned mode: parameter value is split between even and odd channel registers
- 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. The value is loaded after calling Load method.
Version specific information for Freescale 56800/E and HC08 and HCS12 and HCS12X derivatives
Setting is valid for actual speed mode only, initial value is restored after speed mode change.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives
Settings is not affected during speed mode change. It should be handled by the user code.
ANSIC prototype: byte SetRatio15(byte Channel, int16_t Ratio)
- Channel:byte - channel number (0 - 5). The number corresponds to the logical channel number assigned in the component settings, which may not correspond to channel number of the peripheral.
- Ratio:int16_t - 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.
Version specific information for Freescale HCS08 and ColdFireV1 derivatives - FTM peripheral:
- edge-aligned mode: parameter value is written into odd channel register; even channel register is not affected (zero value assumed);
- center-aligned mode: parameter value is split between even and odd channel registers
- Return value:byte - Error code, possible codes:
ERR_OK - OK ERR_NOTAVAIL - Channel is disabled ERR_RANGE - Parameter Channel or Ratio is out of range
- Method not supported for Freescale ColdFireV1 and HCS08 derivatives.
-
Swap
- Swap channel pairs.
ANSIC prototype: byte Swap(TChannelPairs SwapPair)
- SwapPair:TChannelPairs - Logical 1 swaps channel pair from its base position. Logical 0 doesn't swap pair from its base position.
- 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 any Fault with "manual clearing mode" is enabled.
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.
|