Skip to content

broadcom - Pin.c setting of JTAG pins -- should it have pull-down? #5787

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

Closed
jerryneedell opened this issue Dec 28, 2021 · 7 comments
Closed
Labels
broadcom Raspberry Pis with Broadcom chips bug

Comments

@jerryneedell
Copy link
Collaborator

jerryneedell commented Dec 28, 2021

When the Pins are reset in
https://github.com/adafruit/circuitpython/blob/main/ports/broadcom/common-hal/microcontroller/Pin.c#L53
for the JTAG pins 22-27, the Pins it set to ALT4 then it returns without setting a PullDOWN.
Looikng at the Datasheet, these pins are listed as having pull-downs.
section 5.3 https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf

Sould the be set here?

It seem sot be working as it and it and I f set them as Pull-down it still works. I'm just curious if they should be set .

here is the change I made to test it.

diff --git a/ports/broadcom/common-hal/microcontroller/Pin.c b/ports/broadcom/common-hal/microcontroller/Pin.c
index 1cf86f2b3..f3355a7be 100644
--- a/ports/broadcom/common-hal/microcontroller/Pin.c
+++ b/ports/broadcom/common-hal/microcontroller/Pin.c
@@ -48,14 +48,15 @@ void reset_pin_number(uint8_t pin_number) {
     pin_in_use[pin_number] = false;
     never_reset_pin[pin_number] = false;
     // Reset JTAG pins back to JTAG.
+    BP_PULL_Enum pull = BP_PULL_NONE;
     if (22 <= pin_number && pin_number <= 27) {
         gpio_set_function(pin_number, GPIO_FUNCTION_ALT4);
+        pull = BP_PULL_DOWN;
         return;
     } else {
         gpio_set_function(pin_number, GPIO_FUNCTION_INPUT);
     }
     // Set the pull to match the datasheet.
-    BP_PULL_Enum pull = BP_PULL_NONE;
     if (pin_number < 9 ||
         (33 < pin_number && pin_number < 37) ||
         pin_number > 45) {
@jerryneedell jerryneedell changed the title croadcome - Pin.c setting of JTAG -- should it have pull-down? brroadcom - Pin.c setting of JTAG pins -- should it have pull-down? Dec 28, 2021
@jerryneedell jerryneedell changed the title brroadcom - Pin.c setting of JTAG pins -- should it have pull-down? broadcom - Pin.c setting of JTAG pins -- should it have pull-down? Dec 28, 2021
@tannewt tannewt added broadcom Raspberry Pis with Broadcom chips bug labels Dec 28, 2021
@tannewt
Copy link
Member

tannewt commented Dec 28, 2021

I looked at the current state of pins prior to the first reset and they didn't all match the datasheet. So, I'd go by what works rather than what the datasheet says.

@jerryneedell
Copy link
Collaborator Author

Sounds good. Thanks.

@jerryneedell
Copy link
Collaborator Author

jerryneedell commented Dec 28, 2021

Actually, one more question...
If you set it to ALT4 and return but don't explicitly set the Pull (up/down) then I guess it just stays as it was. Is that OK or do you want to be explicitly setting it to something?

or is it that pull only has meaning if it is set as in input? so it it irrelevant for ALT4
the data sheet does say "The Alternate function table also has the pull state which is applied after a power down."

Interesting difference in the BCM2711 data sheet and the BCM2835 datasheeet
BCM2711

GPIO_PUP_PDN_CNTRL_REG0 Register
Description
The GPIO Pull-up / Pull-down Registers control the actuation of the internal pull-up/down resistors. Reading these
registers gives the current pull-state.
The Alternate function table also has the pull state which is applied after a power down.

BCM2835

GPIO Pull-up/down Register (GPPUD)
SYNOPSIS
The GPIO Pull-up/down Register controls the actuation of the internal pull-up/down
control line to ALL the GPIO pins. This register must be used in conjunction with the 2
GPPUDCLKn registers.
Note that it is not possible to read back the current Pull-up/down settings and so it is the
users’ responsibility to ‘remember’ which pull-up/downs are active. The reason for this is
that GPIO pull-ups are maintained even in power-down mode when the core is off, when
all register contents is lost.
The Alternate function table also has the pull state which is applied after a power down.

@jerryneedell jerryneedell reopened this Dec 28, 2021
@tannewt
Copy link
Member

tannewt commented Dec 29, 2021

Ya, we should probably reset it to the state we want. That's good to know about reading pull back. I think I'm doing that now.

@jerryneedell
Copy link
Collaborator Author

Ya, we should probably reset it to the state we want. That's good to know about reading pull back. I think I'm doing that now.

Would you like me to submit a PR for the change I made above to set them to pull-down or since you are likely making other changes do you want to do that yourself?

@tannewt
Copy link
Member

tannewt commented Dec 30, 2021

Go ahead @jerryneedell. I'm working on Zero support.

@tannewt
Copy link
Member

tannewt commented Jan 6, 2022

This is done in #5798. Thanks @jerryneedell

@tannewt tannewt closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcom Raspberry Pis with Broadcom chips bug
Projects
None yet
Development

No branches or pull requests

2 participants