-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pwm: fix pwm_pin_set_usec on 32 bit MCU #6998
Conversation
Fixes zephyrproject-rtos#6015 Signed-off-by: Thibaut Mauron <[email protected]>
@MaureenHelm can you take a look at this please? |
@tmauron curious under what conditions you see this issue. |
@tmauron apologies for the huge delay in reviewing this PR. We are now catching up and we've added a few reviewers, hopefully this will be reviewed soon. |
@cvinayak @pizi-nordic can you please review this PR? |
if (pulse_cycles >= ((u64_t)1 << 32)) { | ||
return -ENOTSUP; | ||
} | ||
period_cycles = ((u32_t)cycles_per_sec / USEC_PER_SEC) * period; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are loosing some precision if the cycles_per_sec
are not multiple of USEC_PER_SEC
,
Moreover, if cycles_per_sec
are less than USEC_PER_SEC
, you will always end with period_cycles
and pulse_cycles
= 0.
Could you please elaborate where is the problem you are trying to fix?
If #6958 - "Update PWM API for dynamic prescaler computation", 'drivers should be able to handle directly pwm_pin_set_usec', gets developed and merged, any problems that may exist with calculating period_cycles will be handled in the drivers pin_set function instead. |
Fixes #6015
Signed-off-by: Thibaut Mauron [email protected]