# Pico PWM clashes: pins share slices, so frequency and duty change together

> Plan Pico PWM: pins come in pairs on shared slices, so two outputs on one slice share a frequency; spread servos and motors across slices.

Canonical: https://roboticsengineering.in/fix/raspberry-pi-pico-pwm-servo-motor-pins-slices/ | Published: 2026-11-03 | Updated: 2026-11-04

**PWM pins share slices.** Both pins in a pair run at the same frequency.

## What the message means

The chip has a set of PWM blocks, and each drives two pins. Changing the frequency on one pin changes its partner.

## Fix it in this order

1. Look up which slice each pin belongs to in the pin diagram.
2. Use the same frequency on both pins of a slice.
3. Use 50 Hz for hobby servos on their own slice.
4. Put motor drivers on a different slice from servos.
5. Set the frequency before you set the duty.
6. Test each output alone first.

## Why it happens

The RP2040 on the Pico has eight PWM slices, and each slice drives two output channels, A and B, giving 16 channels in all. The two channels of a slice share one counter, so they share one frequency, although each keeps its own duty cycle. The slice number follows from the GPIO number: GPIO 0 and 1 are slice 0, GPIO 2 and 3 are slice 1, and so on, wrapping after GPIO 15 so that GPIO 16 and 17 are slice 0 again.

That is why a servo at 50 Hz twitches when you start a motor driver at 20 kHz on the neighbouring pin: the second call changed the frequency for both. Put the servo and the motor on pins in different slices and the two settings stop fighting.

```
from machine import Pin, PWM
servo = PWM(Pin(14))   # slice 7, channel A
servo.freq(50)
motor = PWM(Pin(16))   # slice 0, channel A
motor.freq(20000)
```

*The example above has not been run on hardware here; test it on your own board.*

## If you see this, do this

| You see | Do this |
| --- | --- |
| Servo twitches when a motor starts | Shared slice frequency. |
| No output on a pin | Check slice and wiring. |

## Related

[servo pulse range](https://roboticsengineering.in/fix/hobby-servo-signal-pulse-range-500-2500/), [servo jitter](https://roboticsengineering.in/fix/arduino-servo-jitter-twitching/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

## Why this happens

The RP2040 has eight PWM slices. Each slice has one counter that sets the period and two compare values, one for channel A and one for channel B, which set the duty of each output. Because the counter is shared, both outputs of a slice must use the same frequency. Only the duty can differ.

The slice and channel come directly from the GPIO number: slice = (GPIO / 2) modulo 8, and channel A for even pins, B for odd ones. GPIO 14 and 15 are slice 7, and GPIO 16 and 17 are slice 0, since the numbering wraps. Setting the frequency of one pin silently changes its neighbour, which is why a servo twitches when a motor starts.

## How to confirm the cause

- Work out the slice for each pin you use with the formula above and list them. Two PWM pins in one slice with different frequencies is a conflict.
- Print the frequency of each object after setting everything up. The last frequency call on a slice wins.
- Check with a scope or logic analyser if you can: a servo line should show 50 Hz, and a motor line a much higher rate.
- Move one of the two outputs to a pin in a different slice and run again.
- Set the frequency before the duty cycle on each pin.

## Worked example

MicroPython on a Pico. The servo is on GPIO 14 (slice 7) and the motor driver on GPIO 16 (slice 0), so they do not share a slice:

```
from machine import Pin, PWM

def slice_of(gpio): return (gpio >> 1) & 7

servo = PWM(Pin(14)); servo.freq(50)
motor = PWM(Pin(16)); motor.freq(20000)
print(slice_of(14), slice_of(16))   # 7 0

# 1.5 ms pulse at 50 Hz: 1.5 / 20 x 65535 = 4915
servo.duty_u16(4915)
motor.duty_u16(32768)               # about 50 percent
```

## Common mistakes

- Putting a servo and a motor driver on pins 14 and 15, or any other pair of the same slice.
- Setting the duty first and the frequency second, so the duty is recomputed on a new period.
- Assuming that each pin has its own timer, as on some other boards.
- Using a very low frequency that the divider cannot reach; the lowest is around 7 Hz at the default clock.
- Not checking which pins are actually free on your board variant.

## If this did not fix it

- Servo power: a servo drawing from a weak supply also twitches.
- The servo expects a different pulse range; calibrate the minimum and maximum.
- Library differences: in another language the call names change, but the slice rule is the same.
