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

RP2040 pin drive strength #7206

Open
HelenFoster opened this issue Nov 14, 2022 · 7 comments
Open

RP2040 pin drive strength #7206

HelenFoster opened this issue Nov 14, 2022 · 7 comments
Labels
enhancement rp2040 Raspberry Pi RP2040
Milestone

Comments

@HelenFoster
Copy link

We talked about it on the Discord a few days ago but I thought I should raise it here too.

  • The datasheet says "The GPIOs on RP2040 have four different output drive strengths, which are nominally called 2, 4, 8 and 12mA modes", and the default is 4mA.
  • CircuitPython currently sets it to 12mA in DigitalInOut and UART, and doesn't set it for PulseOut, PWMOut or PIO.
  • CircuitPython policy is normally to use max drive strength except where there's a particular reason not to?
  • There could potentially be issues with capacitive loads and interference?

#1270 nrf pin drive strength discussion

// Turn on "strong" pin driving (more current available).

// Turn on "strong" pin driving (more current available).

@HelenFoster
Copy link
Author

Looks like this field is not reset on deinit, so e.g. behaviour of PWMOut currently depends whether there was a DigitalInOut before.

void reset_pin_number(uint8_t pin_number) {

# Pi Pico with 220R between GP0 and GND
import board, digitalio, pwmio
p = pwmio.PWMOut(board.GP0, frequency=1000, duty_cycle=0xffff)
# 2.69V
p.deinit()
p = digitalio.DigitalInOut(board.GP0)
p.switch_to_output(True)
# 2.96V
p.deinit()
p = pwmio.PWMOut(board.GP0, frequency=1000, duty_cycle=0xffff)
# 2.96V

Do we want max drive strength for everything? Would it be done like in DigitalInOut?

@dhalbert
Copy link
Collaborator

Do we want max drive strength for everything? Would it be done like in DigitalInOut?

Yes, that should be fine. Do it like

// Turn on "strong" pin driving (more current available).
hw_write_masked(&padsbank0_hw->io[pin],
PADS_BANK0_GPIO0_DRIVE_VALUE_12MA << PADS_BANK0_GPIO0_DRIVE_LSB,
PADS_BANK0_GPIO0_DRIVE_BITS);

@HelenFoster
Copy link
Author

PIO looks complicated. Actually, if it's for everything, might it be better to set it for all the relevant pins on startup and then leave it alone in the individual IO libs?

@dhalbert
Copy link
Collaborator

PIO looks complicated. Actually, if it's for everything, might it be better to set it for all the relevant pins on startup and then leave it alone in the individual IO libs?

That makes sense. Are you interested in doing a PR?

@dhalbert dhalbert added this to the 8.x.x milestone Nov 15, 2022
@dhalbert dhalbert added the rp2040 Raspberry Pi RP2040 label Nov 15, 2022
@dhalbert dhalbert modified the milestones: 8.x.x, Long term Nov 15, 2022
@HelenFoster
Copy link
Author

At a high level I was thinking it makes sense to put this in one place, but I don't really have any idea where it would go or how you decide which pins are eligible.

@eightycc
Copy link

eightycc commented Sep 1, 2023

If no one objects, I'd like to pick up this issue.

@HelenFoster
Copy link
Author

@eightycc Note that the drive strength for PIO was reduced since the previous discussion, to fix a specific use. (I was worried when I saw that, but fortunately it doesn't seem to affect my project too much.) #7558

So it seems what I was saying in the OP is not the case, and we really need the general drive strength API, as you already started discussing over here: #1270 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement rp2040 Raspberry Pi RP2040
Projects
None yet
Development

No branches or pull requests

3 participants