← index #4814Issue #3194
Related · high · value 2.041
QUERY · ISSUE

stm32 NUCLEO boards: pin name conflicts

openby chrismas9opened 2019-05-26updated 2019-05-29
port-stm32

On pyboard:
>>> import pyb
>>> pin = pyb.Pin('A2')
>>> pin
Pin(Pin.cpu.A2, mode=Pin.ALT, pull=Pin.PULL_UP, af=Pin.AF7_USART2)

On many NUCLEO boards:
>>> import pyb
>>> pin = pyb.Pin('A2')
>>> pin
Pin(Pin.cpu.A4, mode=Pin.ANALOG)

On NUCLEO boards (eg NUCLEO_F091RC or L476RG) 'A2' maps to cpu pin A4.

This is because pins.csv has a board pin entry 'A2' for the Arduino analog pin name. Quite a few of the Arduino pin names are the same as the STM32 port names.

I can think of 4 solutions:

  1. Remove the Arduino pin names from pins.csv.
  2. Prepend the Arduino name with something, eg connector name - CN8_A2
  3. Require cpu pins to be entered with a P, eg pyb.Pin('PA2').
  4. Require cpu pins to be entered with a cpu. prefix, eg pyb.Pin('cpu.A2').

Options 3 & 4 are most likely to break existing code, although this could be avoided by mapping the short names in the csv file, eg A2,PA2 or A2,cpu.A2, for non NUCLEO ports.

Option 3 may not work for all MCUs as some MCUs don't have a P, just A2, etc.

I am currently using option 2, ie make board pin names unique.

Any suggestions on the best fix?

CANDIDATE · ISSUE

Cannot change GPIO value

closedby caprieleopened 2017-07-03updated 2017-07-04

Hi,
I'd like to change the value of a GPIO pin (on NUCLEO_F429ZI) connected to a led. I've tried different method on different pins. In particular the following code is working
pyb.Pin(pyb.Pin.cpu.B0,pyb.Pin.OUT).on()
istead this one is NOT working
pyb.Pin(pyb.Pin.cpu.B14,pyb.Pin.OUT).on()

Is this problem related to the fact that the UART_REPL is equal to PYB_UART_3? (On this board PB14 has the function of USART3_RTS). However if I write a simple program using mbed this led (LED3) is fully working.

When I start the board the P_B14 has this value:
>>> pyb.Pin.cpu.B14
Pin(Pin.cpu.B14, mode=Pin.ALT, af=12)

Thanks to all!

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