Jump to main content

##

# 3.3.22.6 mcPwm_IntegerScale

## C

    /* PWM scaling*/
    int16_t mcPwm_IntegerScale( const float32_t factor, int16_t input )

## Summary

Perform the PWM output scaling.

## Description

This function scales an integer input by a floating-point factor. It multiplies the input by the factor and returns the result as an integer. This is useful for adjusting PWM duty cycles in relation to the PWM period counter.

## Precondition

None.

## Parameters

Param | Description
--- | ---
factor | The floating-point scaling factor used to multiply the input value.
input | The integer value to be scaled.

## Returns

The result of scaling the input by the factor, cast to an integer type

## Example

    float32_t uA;
    int16_t pwmPeriodCount;;
    int16_t pDutyA;

    /** PWM scaling*/
    pDutyA = mcPwm_IntegerScale(uA, pwmPeriodCount);

## Remarks

Note: The function uses inline assembly for performance optimization, making it suitable for real-time applications where execution speed is critical.