63 #define PWM_LOWER_THRESHOLD_PERM (1u)
66 #define PWM_UPPER_THRESHOLD_PERM (999u)
69 #define PWM_FULL_PERIOD_PERM (1000u)
91 etpwm_config_reg_t etPwmConfig = {0};
92 etpwm1GetConfigValue(&etPwmConfig, CurrentValue);
93 return etPwmConfig.CONFIG_TBPRD;
100 uint32_t counterValue = (((uint32_t)basePeriod * (uint32_t)dutyCycle_perm) /
PWM_FULL_PERIOD_PERM);
102 FAS_ASSERT(counterValue <= (uint16_t)UINT16_MAX);
103 return (uint16_t)counterValue;
124 FAS_ASSERT(dutyCycle_perm <= (uint16_t)INT16_MAX);
125 int16_t intermediateDutyCycle_perm = (int16_t)dutyCycle_perm +
pwm_kLinearOffset;
127 if (intermediateDutyCycle_perm < 0) {
128 intermediateDutyCycle_perm = 0;
130 uint16_t correctedDutyCycle_perm = (uint16_t)intermediateDutyCycle_perm;
144 #ifdef UNITY_UNIT_TEST
145 extern int16_t TEST_PWM_GetLinearOffset(
void) {
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
long FSYS_RaisePrivilege(void)
raise privilege
void PWM_SetDutyCycle(uint16_t dutyCycle_perm)
Set the duty cycle of the PWM (currently only channel 1A)
void PWM_StopPwm(void)
Stop the PWM (stops all configured ePWM channels)
static uint16_t PWM_GetEtpwmTimePeriod(void)
#define PWM_UPPER_THRESHOLD_PERM
#define PWM_FULL_PERIOD_PERM
static uint16_t PWM_ComputeCounterValueFromDutyCycle(uint16_t dutyCycle_perm)
void PWM_StartPwm(void)
Start the PWM (starts all configured ePWM channels)
#define PWM_LOWER_THRESHOLD_PERM
static const int16_t pwm_kLinearOffset
PWM driver for the TMS570LC43xx.