← index #16211Issue #16370
Off-topic · high · value 0.286
QUERY · ISSUE

Input Pins 1 and 2 do not work of the 8

openby magliaralopened 2024-11-11updated 2026-03-24
bugport-stm32

Port, board and/or hardware

ARDUINO_OPTA

MicroPython version

MicroPython v1.24.0 on 2024-10-25; Arduino OPTA with STM32H747

Reproduction

import machine
from machine import Pin

pin1 = Pin("IN_1")
pin1.value()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'value'

pin1.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self._callback)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'irq'

pin2 = Pin("IN_2")
pin2.value()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'value'

pin2.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self._callback)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Pin' object has no attribute 'irq'

Expected behaviour

pin3 = Pin("IN_3")
pin3.value()
0

Observed behaviour

Pin 1 and 2 do not work.
It seems that the pin 1 and 2 are not instantiated correctly. Whether with IN_1 or PA0_C.
Pins 3 to 8 work both ways.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

Problem with 'machine.Pin()' on Teensy 4.1 for the GPIOs

closedby MicroControleurMondeopened 2024-12-06updated 2024-12-06
bug

Port, board and/or hardware

Platform : Teensy 4.1

MicroPython version

MicroPython v1.24.0 on 2024-10-25; Teensy 4.1 with MIMXRT1062DVJ6A

Reproduction

from machine import Pin

p0 = Pin('D0', Pin.OUT) # create output pin on GPIO0
p0.on() # set pin to "on" (high) level
p0.off() # set pin to "off" (low) level
p0.value(1) # set pin to on/high

p2 = Pin('D2', Pin.IN) # create input pin on GPIO2
print(p2.value()) # get value, 0 or 1

p4 = Pin('D4', Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
p5 = Pin('D5', Pin.OUT, value=1) # set pin high on creation

p6 = Pin(pin.cpu.GPIO_B1_15, Pin.OUT) # Use the cpu pin name.

Expected behaviour

The code shoud create and configures several GPIO pins on the MCU in input and output mode.
The output should be visible on the console for the value of 'print(p2.value())'.

Observed behaviour

1
Traceback (most recent call last):
File "<stdin>", line 14, in <module>
NameError: name 'pin' isn't defined

Additional Information

I have tried many other scripts using 'machine.Pin () ' and systematically I come across this error : 'pin' isn't defined
I have never seen this with ESP32, RP2040 or Pyboard...

The problem is specific to the use of machine.Pin() for the GPIOs.
Direct access to the registers via the memory addresses of these same GPIOs poses no problem.
I went to search the NXP doc and I pulled out some info about GPIO.

Start address End address Size Region NIC port
400C_0000 400C_3FFF 16KB AIPS-1 GPIO5
401C_4000 401C_7FFF 16KB AIPS-2 GPIO4
401C_0000 401C_3FFF 16KB AIPS-2 GPIO3
401B_C000 401B_FFFF 16KB AIPS-2 GPIO2
401B_8000 401B_BFFF 16KB AIPS-2 GPIO1
4200_C000 4200_FFFF 16KB AIPS-5 GPIO9
4200_8000 4200_BFFF 16KB AIPS-5 GPIO8
4200_4000 4200_7FFF 16KB AIPS-5 GPIO7
4200_0000 4200_3FFF 16KB AIPS-5 GPIO6

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied