I am fairly new to Raspberry PI GPIO pins. I have some simple code which sets Pin 29 (BCM 5 in this picture) as an IN (READ) Pin and then reads from it after boot and on raspberry pi 3 it has always been Low however on the raspberry pi 4 it seems to be High.
I am trying to understand why this is the case.
I was not able to find any specification on why that is. My understanding is that the raspberry pi 4 uses BCM2838 however the only spec sheet I can find is this one for the BCM2835 (https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf)
On page 102 there is a table with alternate functions showing the default pull values and for Pin 29 is has a dash (-) and some comment at the bottom about white values not to be used but I am not certain whether this is relevant
The Go code below reproduces the issue by performing a simple READ on the pin (We use the latest periph
library with support for rpi 4
package main
import (
"fmt"
"log"
"time"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/host"
"periph.io/x/periph/host/rpi"
)
var (
readPin = rpi.P1_29
)
func main() {
fmt.Println("Initializing periph host...")
if _, err := host.Init(); err != nil {
log.Panicf("failed to initialize periph host: %v", err)
}
if err := readPin.In(gpio.PullDown, gpio.NoEdge); err != nil {
log.Panicf("failed to set read pin to In(): %v", err)
}
ticker := time.NewTicker(2* time.Second)
want := gpio.Low
for {
select {
case <-ticker.C:
time.Sleep(time.Millisecond)
actual := readPin.Read()
if actual != want {
log.Printf("ERROR: Actual: %t != Wanted: %t", actual, want)
continue
}
log.Println("EVERYTHING WAS FINE")
}
}
}
Any chance somebody can shine a light on the situation? Is there some undocumented behaviour to Pin 29 I am missing causing this? Is this expected behaviour (and if so an explanation would be nice)