Infineon Motor Control Library

General Description

All of the MCDI functions are instance-based; function names start with the instance name and depend on user configuration.

The instance name 'myMotor' has been chosen for the current documentation.

Functions

cy_rslt_t myMotor_init (void)
 Performs the Motor Control instance initialization sequence: More...
 
__STATIC_INLINE cy_rslt_t myMotor_enable (void)
 Performs the Motor Control instance enable sequence: More...
 
cy_rslt_t myMotor_start (void)
 Performs the Motor Control instance start sequence: More...
 
__STATIC_FORCEINLINE uint32_t myMotor_IUP_get_result (void)
 Gets the ADC channel result in raw counts. More...
 
__STATIC_INLINE void myMotor_mod_U_set (uint16_t cmp0, uint16_t cmp1)
 Updates the Modulator PWM data array with specific compare0/1 values for each phase. More...
 
__STATIC_INLINE void myMotor_mod_ADC_trig_set (uint16_t first, uint16_t second)
 Updates the Modulator Fast Timer compare0/1 values to generate two ADC sampling triggers for the single-shunt algorithm. More...
 
__STATIC_INLINE void myMotor_mod_update (void)
 Updates the Modulator peripharal registers with the values from the data array. More...
 
__STATIC_INLINE cy_rslt_t myMotor_disable (void)
 Performs the Motor Control instance Disable (Stop) sequence: More...
 

Function Documentation

◆ myMotor_init()

cy_rslt_t myMotor_init ( void  )

Performs the Motor Control instance initialization sequence:

  • Initializes all PWMs, Sync, Fast and Slow Timers (The HPPASS is a common resource, it is initialized outside of the solution level)
Returns
The function operation status, see Status
Note
The "myMotor" instance initialization during startup will be performed if the "Initialize During Startup" checkbox is checked during
the configuration process in the Device Configurator.
Otherwise, the "myMotor_init" function call shall be performed by the applicatin code, as shown in the code snippet below.
Function Usage
/* Assume the HPPASS (as well as other shared resource) is already initialized */
myMotor_init(); /* Initialize all the motor-specific PWMs and Timers */
/* Initialize all the rest of solutions/peripherals */
myMotor_enable(); /* Enable all the motor-specific PWMs and Timers, after this action they are sensitive to input triggers */
/* Enable all the rest of solutions/peripherals */
myMotor_start(); /* Safely start the shared resources (if not started yet) and all the motor-specific PWMs and Timers synchronously (except the Slow Timer - it is started asynchronously) */
cy_rslt_t myMotor_init(void)
Performs the Motor Control instance initialization sequence:
__STATIC_INLINE cy_rslt_t myMotor_enable(void)
Performs the Motor Control instance enable sequence:
cy_rslt_t myMotor_start(void)
Performs the Motor Control instance start sequence:

◆ myMotor_enable()

__STATIC_INLINE cy_rslt_t myMotor_enable ( void  )

Performs the Motor Control instance enable sequence:

  • Enables all PWMs, Sync, Fast and Slow Timers (after this action, they are sensitive to input triggers).
Returns
The function operation status, see Status
Function Usage
/* Assume the HPPASS (as well as other shared resource) is already initialized */
myMotor_init(); /* Initialize all the motor-specific PWMs and Timers */
/* Initialize all the rest of solutions/peripherals */
myMotor_enable(); /* Enable all the motor-specific PWMs and Timers, after this action they are sensitive to input triggers */
/* Enable all the rest of solutions/peripherals */
myMotor_start(); /* Safely start the shared resources (if not started yet) and all the motor-specific PWMs and Timers synchronously (except the Slow Timer - it is started asynchronously) */

◆ myMotor_start()

cy_rslt_t myMotor_start ( void  )

Performs the Motor Control instance start sequence:

  • Starts the HPPASS, a common resource that should be preconfigured.
  • Starts all PWMs, Sync, and Fast Timers synchronously.
  • Starts the Slow Timer asynchronously.
Returns
The function operation status, see Status
Function Usage
/* Assume the HPPASS (as well as other shared resource) is already initialized */
myMotor_init(); /* Initialize all the motor-specific PWMs and Timers */
/* Initialize all the rest of solutions/peripherals */
myMotor_enable(); /* Enable all the motor-specific PWMs and Timers, after this action they are sensitive to input triggers */
/* Enable all the rest of solutions/peripherals */
myMotor_start(); /* Safely start the shared resources (if not started yet) and all the motor-specific PWMs and Timers synchronously (except the Slow Timer - it is started asynchronously) */

◆ myMotor_IUP_get_result()

__STATIC_FORCEINLINE uint32_t myMotor_IUP_get_result ( void  )

Gets the ADC channel result in raw counts.

The instance-based ADC-channel-based function to get the ADC channel result. This function exists for each MCDI ADC channel, under the naming: [instance_name]_[channel_name]_get_result.

Returns
The ADC channel result value
Note
If ADC DMA is not used, the function gets the value from the peripheral ADC channel result register. If ADC DMA is used, the function gets the value from the RAM cell, where the ADC value is delivered by DMA.
Function Usage
/* For 3-shunt typically three phase currents U/V/W are being measured: */
sensor_iface.i_samp_0.raw = -hw.mcu.adc_scale.i_uvw * (int16_t)myMotor_IUP_get_result();
sensor_iface.i_samp_1.raw = -hw.mcu.adc_scale.i_uvw * (int16_t)myMotor_IVP_get_result();
sensor_iface.i_samp_2.raw = -hw.mcu.adc_scale.i_uvw * (int16_t)myMotor_IWP_get_result();
__STATIC_FORCEINLINE uint32_t myMotor_IUP_get_result(void)
Gets the ADC channel result in raw counts.

◆ myMotor_mod_U_set()

__STATIC_INLINE void myMotor_mod_U_set ( uint16_t  cmp0,
uint16_t  cmp1 
)

Updates the Modulator PWM data array with specific compare0/1 values for each phase.

There are three separate U/V/W functions for each Modulator phase.

Parameters
cmp0The compare0 value.
cmp1The compare1 value. Available only for the asymmetric PWM mode.
Note
If Modulator DMA is not used, the function sets the value directly to the peripheral PWM buffer registers. If Modulator DMA is used, the function sets the value to the RAM cells, from where the DMA delivers value to the peripheral PWM buffer registers.
Function Usage
myMotor_mod_U_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.u)); /* Only compare0 value for the PWM symmetric mode */
myMotor_mod_V_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.v));
myMotor_mod_W_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.w));
__STATIC_INLINE void myMotor_mod_update(void)
Updates the Modulator peripharal registers with the values from the data array.
__STATIC_INLINE void myMotor_mod_U_set(uint16_t cmp0, uint16_t cmp1)
Updates the Modulator PWM data array with specific compare0/1 values for each phase.

◆ myMotor_mod_ADC_trig_set()

__STATIC_INLINE void myMotor_mod_ADC_trig_set ( uint16_t  first,
uint16_t  second 
)

Updates the Modulator Fast Timer compare0/1 values to generate two ADC sampling triggers for the single-shunt algorithm.

Note
Available for the single-shunt topology only.
If Modulator DMA is not used, the function sets the value directly to the peripheral Fast Timer buffer registers. If Modulator DMA is used, the function sets the value to the RAM cells, from where the DMA delivers value to the peripheral Fast Timer buffer registers.
Parameters
firstThe first ADC sample timing value in Fast Timer clock cycles
secondThe second ADC sample timing value in Fast Timer clock cycles

◆ myMotor_mod_update()

__STATIC_INLINE void myMotor_mod_update ( void  )

Updates the Modulator peripharal registers with the values from the data array.

Function content is configuration-dependent.

Function Usage
myMotor_mod_U_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.u)); /* Only compare0 value for the PWM symmetric mode */
myMotor_mod_V_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.v));
myMotor_mod_W_set((uint16_t)(hw.mcu.pwm.duty_cycle_coeff * vars.d_uvw_cmd.w));

◆ myMotor_disable()

__STATIC_INLINE cy_rslt_t myMotor_disable ( void  )

Performs the Motor Control instance Disable (Stop) sequence:

  • Disables (stops) all PWMs, Sync, Fast and Slow Timers.
Returns
The function operation status, see Status
Function Usage
void myMotor_fault_callback(void)
{
myMotor_disable(); /* Disable (stop) all PWMs, Sync, Fast and Slow Timers */
}
__STATIC_INLINE cy_rslt_t myMotor_disable(void)
Performs the Motor Control instance Disable (Stop) sequence: