[STM32F429DISC] Pin is not defined

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
bogdansrb
Posts: 3
Joined: Fri Jan 22, 2021 6:35 pm

[STM32F429DISC] Pin is not defined

Post by bogdansrb » Mon Jan 25, 2021 11:41 am

Greetings,
I've flashed micropython on my STM32F429 discovery board (the one with the LCD) and I get this error while trying to configure the pins:

Code: Select all

>>> led = Pin(PG13, Pin.OUT)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'PG13' isn't defined
I've looked on the board definitions and the pin is indeed defined (https://github.com/micropython/micropyt ... 32F429DISC)
If it matters, I couldn't flash the normal way via dfu, so I converted the dfu file to hex using dfu file manager and then flashed the st link way. I can see the flash storage and connect to repl just fine.

User avatar
jimmo
Posts: 2244
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [STM32F429DISC] Pin is not defined

Post by jimmo » Tue Jan 26, 2021 1:01 am

bogdansrb wrote:
Mon Jan 25, 2021 11:41 am
NameError: name 'PG13' isn't defined
When you use a named string with the machine.Pin constructor it needs to be a string. Also it's just G13 rather than PG13, so:

Code: Select all

machine.Pin('G13', Pin.OUT)
You can also use

Code: Select all

led = Pin.cpu.G13
led.init(Pin.OUT)

Post Reply