1.42.11.13 PWMx_CompareValueSet Function

C

/* x = PWM instance number */

void PWMx_CompareValueSet (PWM_COMPARE cmp_unit, uint16_t cmp_value)

Summary

Writes the compare value for given PWM peripheral and given comparison unit

Description

This function writes compare value in a double buffer register. Update to the actual compare value register happens at the PWM period border when compare period counter expires.

Precondition

PWMx_Initialize() function must have been called first for the associated instance. And associated channel must be running.

Parameters

Param Description
cmp_unit compare unit number
cmp_value compare value which is compared with channel 0 counter

Returns

None

Example

PWM0_Initialize();
PWM0_ChannelsStart(PWM_CHANNEL_0_MASK);
PWM0_CompareValueSet(PWM_COMPARE_0, 0x25);

Remarks

When compare value matches the counter of PWM channel 0, interrupt is generated and also pulse is generated on PWM event line which can be used to synchronize ADC conversion.