When to use PA0 or PA_0? #1954
-
|
There exit two different definitions for hardware Pins. The PA_0 notation can be used with hardware serial, but it seems to cause some trouble with I²C or SPI instances. Here the PA0 notation has to be used. Is there some information on what can be used with which APIs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @MasteringTheMess
when you used this pin number ( |
Beta Was this translation helpful? Give feedback.
Hi @MasteringTheMess
Arduino API uses pin numbers example on uno connector::
D0toD15or 0 to 15A0toA5For convenience with STM32, we define
PYnwhereYis the GPIO port name andnthe GPIO pin number, examplePA0.This pin number is used with all standard Arduino API.
when you used this pin number (
PYn) the core convert it to the typePinName:PY_nThis type is a concatenation, ex:
PA_0 = (PortA << 4) + 0x00,which allows to retrieve the HAL GPIO port and pin.Some extended API allows to use it for convenience or to go faster, ex:
digitalWriteFast.In a general way the pin number is always converted to
PinNameusing macros:digitalPinToPinName.