Skip to content

Commit b82f2d9

Browse files
ananglcarlescufi
authored andcommitted
drivers: pwm_nrf5_sw: Clear GPIOTE config only when switching to GPIO
Otherwise a glitch can appear on the PWM output when the GPIOTE channel is reconfigured (when GPIOTE releases the pin, GPIO takes control and drives it to the last written state which may be different than that used recently by GPIOTE). Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent b04fd97 commit b82f2d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pwm/pwm_nrf5_sw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ static int pwm_nrf5_sw_set_cycles(const struct device *dev, uint32_t channel,
162162
LOG_DBG("channel %u, period %u, pulse %u",
163163
channel, period_cycles, pulse_cycles);
164164

165-
/* clear GPIOTE config */
166-
nrf_gpiote_te_default(NRF_GPIOTE, gpiote_ch);
167-
168165
/* clear PPI used */
169166
ppi_mask = BIT(ppi_chs[0]) | BIT(ppi_chs[1]) |
170167
(PPI_PER_CH > 2 ? BIT(ppi_chs[2]) : 0);
@@ -182,6 +179,9 @@ static int pwm_nrf5_sw_set_cycles(const struct device *dev, uint32_t channel,
182179
pulse_cycles == 0 ? !active_level
183180
: active_level);
184181

182+
/* clear GPIOTE config */
183+
nrf_gpiote_te_default(NRF_GPIOTE, gpiote_ch);
184+
185185
/* No PWM generation for this channel. */
186186
data->pulse_cycles[channel] = 0U;
187187

0 commit comments

Comments
 (0)