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

drivers: pwm: nrfx: Add idle output to PWM driver #83652

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mstasiaknordic
Copy link
Contributor

@mstasiaknordic mstasiaknordic commented Jan 7, 2025

Fast PWM120 prevents GPIO from driving pin with low/high state when PWM duty is 0% or 100%. Idleout feature needs to be used. It can be configured when PWM is disabled and works while it is enabled.

DNM until #82133 is merged. Solution is in the top commit.

Added clock control api for global hsfll used in fast PWM120 driver.

Signed-off-by: Michał Stasiak <[email protected]>
Fast PWM120 prevents GPIO from driving pin with low/high
state when PWM duty is 0% or 100%. Idleout feature needs to
be used. It can be configured when PWM is disabled and works
while it is enabled.

Signed-off-by: Michał Stasiak <[email protected]>
@@ -234,7 +234,13 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
out_level ^= 1;
}

#if NRF_PWM_HAS_IDLEOUT
nrfx_pwm_stop(&config->pwm, true);
nrfy_pwm_channel_idle_set(config->pwm.p_reg, channel, out_level);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't you drive P7 pin directly? because of CTRLSEL==PWM ?

@@ -234,7 +234,13 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
out_level ^= 1;
}

#if NRF_PWM_HAS_IDLEOUT
nrfx_pwm_stop(&config->pwm, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the PWM already stopped at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if previous sequence actually used PWM. Moreover, nrfy_pwm_disable is called within irq handler when used with nrfx_pwm_stop(..., false). In this case, using nrfx_pwm_stop(..., true) makes sure that PWM is disabled and driver is set to initialized state before setting the value of idleout, which would normally be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: PWM Pulse Width Modulation platform: nRF Nordic nRFx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants