Skip to content
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: Update PWM API for dynamic prescaler computation #6958

Open
erwango opened this issue Apr 6, 2018 · 6 comments
Open

pwm: Update PWM API for dynamic prescaler computation #6958

erwango opened this issue Apr 6, 2018 · 6 comments
Assignees
Labels
area: API Changes to public APIs area: PWM Pulse Width Modulation Enhancement Changes/Updates/Additions to existing features

Comments

@erwango
Copy link
Member

erwango commented Apr 6, 2018

As discussed in #5469, current PWM API prevents dynamic prescaler computation.

Indeed, using get_cycles_per_sec in pin_set prevents to adjust PWM prescaler to the requested cycle duration and hence imposes to set it before compilation. Hence PWM application is limited to work in the duration range matching harcoded prescaler value.

I propose to remove function get_cycles_per_sec from API and let driver compute it internally inside pin_set. It seems this function is not used today (not in PWM tests/samples at least).

Drivers should be able to handle directly pwm_pin_set_usec.

@erwango erwango added area: PWM Pulse Width Modulation area: API Changes to public APIs labels Apr 6, 2018
@MaureenHelm MaureenHelm added Enhancement Changes/Updates/Additions to existing features priority: medium Medium impact/importance bug labels Apr 13, 2018
@carlescufi carlescufi changed the title [PWM] Update PWM API for dynamic prescaler computation pwm: Update PWM API for dynamic prescaler computation May 28, 2019
@henrikbrixandersen
Copy link
Member

This needs rethinking after introduction of the PWM capture API functions, which also use the pwm_get_cycles_per_sec() API function.

@manoj153
Copy link
Contributor

Is there a detection mechanism to log error that the provided period is not supported based on the base pre-scaler set value?

@carlescufi carlescufi removed the priority: medium Medium impact/importance bug label Dec 22, 2021
@pszkotak
Copy link
Contributor

pszkotak commented Jan 26, 2022

If I understand correctly with current implementation there is impossible to have e.g. LED blinking with higher period that 250ms using PWM based driver (as in https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/basic/blinky_pwm).

It limits some applications or makes a need for weird workarounds.

@carlescufi, @anangl, is it planned for development? Do you have any estimations?

Edit: Even with the proposed change limitations caused by the min PWM clock at 125kHz and max COUNTERTOP of 32767 still hold. Workarounds are needed for slow blinking use case anyway.

@zephyrbot
Copy link
Collaborator

Hi @anangl,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. Please confirm the issue is correctly assigned and re-assign it otherwise.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

@erwango you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you.

Thanks!

@Tooniis
Copy link

Tooniis commented Oct 12, 2024

I'm trying to generate audio tones with timer output compare on STM32 and the fixed prescaler prevents me from generating accurate frequencies on 16-bit timers while also limiting the range of tones I can generate. Has there been any progress on this?

@erwango
Copy link
Member Author

erwango commented Oct 14, 2024

I'm trying to generate audio tones with timer output compare on STM32 and the fixed prescaler prevents me from generating accurate frequencies on 16-bit timers while also limiting the range of tones I can generate. Has there been any progress on this?

No.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: PWM Pulse Width Modulation Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

9 participants