Encoder Library (Paul Stoffregen) not Working On Arduino Q

Anybody know what pins support interrupts on the Arduino Q? I want to add support to the encoder library?

Just tested and added Support for the Arduino Q and fixed an issue with the Arduino Giga - Zephyr. Here is a link to the PR
Added Arduino Q and fixed Arduino Giga by mjs513 · Pull Request #111 · PaulStoffregen/Encoder

and a link to my branch:
mjs513/Encoder at Arduino_Q

3 Likes

There are STM32U585 MCU (as per datasheet) with --
48 pins : LQFP48 package
48 pins : UFQFPN48
64 pins : LQFP64
90 pins : WLCSP90_SMPS ballout
100 pins : LQFP100
132 pins : UFBGA132_SMPS ballout
144 pins : LQFP144
169 pins : UFBGA169_SMPS ballout

Which one of the above is installed in the Arduino UNO Q Board?

If I get the answer, then my next question would be: which 20-pin of the MCU are connected with the edge connectors of the board?

The Arduino UNO Q uses an STM32U585 microcontroller. Its digital pins likely support external interrupts. Arduino has not published an official interrupt-pin list yet. The safest assumption is that most MCU-side pins can trigger interrupts. Avoid relying on the old UNO rules. Use this pattern:

attachInterrupt(digitalPinToInterrupt(pinA), isrA, CHANGE);

Test each selected pin with a quick ISR. If a pin fails, choose another. The encoder library should work once both pins generate clean edges. This board is new, so community data is limited. Testing is currently the best method to confirm pin capabilities.

1 Like

Performing experiments with the UNOQ can be risky because we are not completely sure whether it is a 3.3 V or 5 V device. I have heard some people saying that the board can accept up to 5 V as to mark logic HIGH input, but it can only output only 3.3 V to mean logic HIGH.

Thats pretty much what I did. Current pin list for interrupts
0-9, 11-13, A0-A5.

Yeah - been testing at 3.3v

Accoring to Arduino documents, Arduino UNO Q contains the following 169-pin STM32U585 MCU. (Package: UFBGA169_SMPS ballout)

Now, the question is: which signals (along with alternate functions) are available on the headers of the board?

D0-pin (DPin-0 at Header) of the header is connected with PB7 (PPin-59, default IO line after power up reset) of the MCU. The following Table shows alternate pin functions that the STM32U585 can route to D0-pin.

Alternate Signal/PPin-F5 Function Type Typical Use Case
LPTIM1_IN2 Low-Power Timer 1 Input External event counting or timing in low-power mode
TIM4_CH2 Timer 4, Channel 2 PWM output, input capture, or general timing
TIM8_BKIN Timer 8 Break Input Fault shutdown for PWM outputs (e.g., motor control)
I2C1_SDA (boot) I²C1 Data / Bootloader I²C communication or MCU bootloader interface
I2C4_SDA I²C4 Data Communication with sensors or peripherals
MDF1_CKI5 Sigma-Delta Modulator Clock Input Audio/signal processing using MDF1 ADC filters
USART1_RX UART Receive (USART1) Receiving serial data
UART4_CTS UART Clear To Send Hardware flow control for UART4
TSC_G2_IO4 Touch Sensing Controller, Group 2 IO4 Capacitive touch input (buttons/sliders)
DCMI_VSYNC / PSSI_RDY Camera interface sync / PSSI ready Frame synchronization or parallel data ready signal
FMC_NL Flexible Memory Controller No-Latch External memory interfacing (SRAM, NOR/NAND)
TIM17_CH1N Timer 17, Complementary Channel 1 Advanced PWM for motor/H-bridge control
EVENTOUT General-purpose event output Trigger other peripherals or external devices
COMP2_INM1 Comparator 2 Analog comparison (voltage threshold detection)
PVD_IN Programmable Voltage Detector Voltage monitoring, brown-out detection
WKUP4 Power management Wake MCU from sleep/standby

Going to take a crack at this. Pin usuage is defined in the ArduinoCore-zephy and zephyr-rtos since the Core is built on top of the Zephyr RTOS. Its not as easy as it once was for avr or mbed.

To start you can see what the pin usage if you look at the overlay first in the Core for the Arduino Q: ArduinoCore-zephyr/variants/arduino_uno_q_stm32u585xx/arduino_uno_q_stm32u585xx.overlay at main · arduino/ArduinoCore-zephyr

then if you look at the conf file in the same directory you can see whats enabled: ArduinoCore-zephyr/variants/arduino_uno_q_stm32u585xx/arduino_uno_q_stm32u585xx.conf at main · arduino/ArduinoCore-zephyr

Now since the core is built on top of Zephyr you need to look in Zephyr RTOS for more info on functions that are referenced but not defined in those files. Since this is the Arduino Q look at:
zephyr/boards/arduino/uno_q/arduino_uno_q-common.dtsi at e09d0adf577189d906febab93358ff3ac2be5e18 · zephyrproject-rtos/zephyr

In Zephyr things are defined in the device tree and then you can use an overlay to add/change things.

Thats the easy explanation for more info you can do a search but here are a couple of links

Introduction to Zephyr Part 4: Devicetree Tutorial

Introduction to devicetree — Zephyr Project Documentation

@ptillisch and @KurtE might be able to explain more or if I said anything wrong.

Also here is the whole list of alternate pins to the board pins that @KurtE put together
Arduino_UNO_Q/Documents at main · KurtE/Arduino_UNO_Q

Thanks for the information.

I usually ask AI to get the mapping; but, I have no Arduino UNOQ to validadte their responses. For example: For example:

I have asked this: Pls, provide me in tabular form the DPin mapping of Arduino UNO Q with signals of STM32U585.

This is the response to validadte which I need physical testing using UNOQ which I am missing at the moment.

Arduino-style pin / Header STM32U585 MCU pin Function / Notes
Digital I/O (JDIGITAL header)
D0 PB7 USART1_RX Manuals++1
D1 PB6 USART1_TX Manuals+
D2 PB3 GPIO / TIM2_CH2 / general Scribd
~D3 (PWM) PB0 PWM / TIM3_CH3 / OPAMP2_OUTPUT (special) Scribd+1
D4 PA12 GPIO / other functions Manuals+
~D5 (PWM) PA11 PWM / TIM1_CH4 / others Manuals+
~D6 (PWM) PB1 PWM / TIM3_CH4 / general I/O Scribd
D7 PB2 GPIO / general I/O Manuals+
D8 PB4 GPIO / TIM3_CH1 (timer) Scribd+1
~D9 (PWM) PB8 PWM / TIM4_CH3 / general I/O Scribd+1
~D10 (PWM / SS) PB9 PWM / SPI2_SS (chip-select) / general I/O Scribd+1
~D11 (PWM / MOSI) PB15 PWM / SPI2_MOSI / general I/O Scribd+1
D12 (MISO) PB14 GPIO / SPI2_MISO / general I/O Scribd+1
D13 (SCK) PB13 GPIO / SPI2_SCK / general I/O Scribd+1
D20 (I2C SDA) PB11 I2C2_SDA (3.3 V logic) Manuals++1
D21 (I2C SCL) PB10 I2C2_SCL (3.3 V logic) Manuals++1
Analog / Power / Special Header (JANALOG, etc.)
A0 / D14 PA4 ADC / Analog input (3.3 V) Manuals++1
A1 / D15 PA5 ADC / Analog input (3.3 V) Manuals++1
A2 / D16 PA6 ADC / Analog input (3.3 V) Manuals++1
A3 / D17 PA7 ADC / Analog input (3.3 V) Manuals++1
A4 / D18 PC1 ADC or I²C3_SDA — when used as I2C, use 3.3 V pull-ups only Arduino Documentation+1
A5 / D19 PC0 ADC or I²C3_SCL — same 3.3 V logic constraint for I²C Arduino Documentation+1
QWIIC Connector (I²C)
SDA (QWIIC) PD13 I2C4_SDA (3.3 V logic) Arduino Documentation+1
SCL (QWIIC) PD12 I2C4_SCL (3.3 V logic) Arduino Documentation+1
JSPI Header (SPI)
SPI MISO PC2 SPI2 MISO (3.3 V logic) Scribd+1
SPI MOSI PC3 SPI2 MOSI (3.3 V logic) Scribd+1
SPI SCK PD1 SPI2 SCK (3.3 V logic) Scribd+1

@GolamMostafa as @Merlin513 mentioned each of the pins on these boards has
many different possible usages. I extracted all of the information from the processors
reference manual and correlated, it to the pins as they are connected on the board.
There is a different thread on this, but, the start of this document looks like:

Arduino Pin usage Port AF0 AF1 AF2 AF3 AF4 AF5 AF6 AF7 AF8 AF9 AF10 AF11 AF12 AF13 AF14 AF15
0 D0 PB7 - LPTIM1_IN2 TIM4_CH2 TIM8_BKIN I2C1_SDA I2C4_SDA MDF1_CKI5 USART1_RX UART4_CTS TSC_G2_IO4 DCMI_VSYNC/
PSSI_RDY
- FMC_NL - TIM17_CH1N EVENTOUT
1 D1 PB6 - LPTIM1_ETR TIM4_CH1 TIM8_BKIN2 I2C1_SCL I2C4_SCL MDF1_SDI5 USART1_TX - TSC_G2_IO3 DCMI_D5/PSSI_D5 - - SAI1_FS_B TIM16_CH1N EVENTOUT
2 D2 PB3 JTDO/
TRACESWO
TIM2_CH2 LPTIM1_CH1 ADF1_CCK0 I2C1_SDA SPI1_SCK SPI3_SCK USART1_
RTS/USART1_
DE
- - CRS_SYNC LPGPIO1_P11 SDMMC2_D2 SAI1_SCK_B - EVENTOUT
3 D3 PB0 - TIM1_CH2N TIM3_CH3 TIM8_CH2N LPTIM3_CH1 SPI1_NSS - USART3_CK - - OCTOSPIM_P1_IO1 LPGPIO1_P9 COMP1_OUT AUDIOCLK - EVENTOUT
4 D4 PA12 - TIM1_ETR - - - SPI1_MOSI OCTOSPIM_
P2_NCS
USART1_
RTS/USART1_
DE
- FDCAN1_TX - - - - - EVENTOUT
5 D5 PA11 - TIM1_CH4 TIM1_BKIN2 - - SPI1_MISO - USART1_CTS - FDCAN1_RX - - - - - EVENTOUT
6 D6 PB1 - TIM1_CH3N TIM3_CH4 TIM8_CH3N LPTIM3_CH2 - MDF1_SDI0 USART3_
RTS/USART3_
DE
LPUART1_
RTS/LPUART1_
DE
- OCTOSPIM_P1_IO0 LPGPIO1_P3 - - LPTIM2_IN1 EVENTOUT
7 D7 PB2 - LPTIM1_CH1 - TIM8_CH4N I2C3_SMBA SPI1_RDY MDF1_CKI0 - - - OCTOSPIM_
P1_DQS
UCPD1_
FRSTX1
- - - EVENTOUT
8 D8 PB4 NJTRST LPTIM1_CH2 TIM3_CH1 ADF1_SDI0 I2C3_SDA SPI1_MISO SPI3_MISO USART1_CTS UART5_RTS/
UART5_DE
TSC_G2_IO1 DCMI_D12/
PSSI_D12
LPGPIO1_P12 SDMMC2_D3 SAI1_MCLK_B TIM17_BKIN EVENTOUT
9 D9 PB8 - - TIM4_CH3 SAI1_CK1 I2C1_SCL MDF1_CCK0 SPI3_RDY - SDMMC1_CKIN FDCAN1_RX DCMI_D6/PSSI_D6 SDMMC2_D4 SDMMC1_D4 SAI1_MCLK_A TIM16_CH1 EVENTOUT
10 D10 PB9 - IR_OUT TIM4_CH4 SAI1_D2 I2C1_SDA SPI2_NSS - - SDMMC1_CDIR FDCAN1_TX DCMI_D7/PSSI_D7 SDMMC2_D5 SDMMC1_D5 SAI1_FS_A TIM17_CH1 EVENTOUT
11 D11 PB15 RTC_REFIN TIM1_CH3N LPTIM2_IN2 TIM8_CH3N - SPI2_MOSI MDF1_CKI2 - - - - FMC_NBL1 SDMMC2_D1 SAI2_SD_A TIM15_CH2 EVENTOUT
12 D12 PB14 - TIM1_CH2N LPTIM3_ETR TIM8_CH2N I2C2_SDA SPI2_MISO MDF1_SDI2 USART3_
RTS/USART3_
DE
- TSC_G1_IO3 - - SDMMC2_D0 SAI2_MCLK_A TIM15_CH1 EVENTOUT
13 D13 PB13 - TIM1_CH1N LPTIM3_IN1 - I2C2_SCL SPI2_SCK MDF1_CKI1 USART3_CTS LPUART1_CTS TSC_G1_IO2 - - - SAI2_SCK_A TIM15_CH1N EVENTOUT
14 A0 PA4 - - - OCTOSPIM_P1
_NCS
- SPI1_NSS SPI3_NSS USART2_CK - - DCMI_HSYNC/
PSSI_DE
- - SAI1_FS_B LPTIM2_CH1 EVENTOUT
15 A1 PA5 CSLEEP TIM2_CH1 TIM2_ETR TIM8_CH1N PSSI_D14 SPI1_SCK - USART3_RX - - - - - - LPTIM2_ETR EVENTOUT
16 A2 PA6 CDSTOP TIM1_BKIN TIM3_CH1 TIM8_BKIN DCMI_PIXCL
K/PSSI_
PDCK
SPI1_MISO - USART3_CTS LPUART1_CTS - OCTOSPIM_P1_IO3 LPGPIO1_P2 - - TIM16_CH1 EVENTOUT
17 A3 PA7 SRDSTOP TIM1_CH1N TIM3_CH2 TIM8_CH1N I2C3_SCL SPI1_MOSI - USART3_TX - - OCTOSPIM_P1_IO2 - - LPTIM2_CH2 TIM17_CH1 EVENTOUT
18 A4 PC1 TRACED0 LPTIM1_CH1 - SPI2_MOSI I2C3_SDA - MDF1_CKI4 - LPUART1_TX - OCTOSPIM_P1_IO4 - SDMMC2_CK SAI1_SD_A - EVENTOUT
19 A5 PC0 - LPTIM1_IN1 - OCTOSPIM_
P1_IO7
I2C3_SCL SPI2_RDY MDF1_SDI4 - LPUART1_RX - - - SDMMC1_D5 SAI2_FS_A LPTIM2_IN1 EVENTOUT
20 D20/SDA PB11 - TIM2_CH4 - I2C4_SDA I2C2_SDA SPI2_RDY - USART3_RX LPUART1_TX - OCTOSPIM_
P1_NCS
- COMP2_OUT - - EVENTOUT
21 D21/SCL PB10 - TIM2_CH3 LPTIM3_CH1 I2C4_SCL I2C2_SCL SPI2_SCK - USART3_TX LPUART1_RX TSC_SYNC OCTOSPIM_P1_CLK LPGPIO1_P4 COMP1_OUT SAI1_SCK_A - EVENTOUT
22 D22/JSPI PC2 - LPTIM1_IN2 - - - SPI2_MISO MDF1_CCK1 - - - OCTOSPIM_P1_IO5 LPGPIO1_P5 - - - EVENTOUT
23 D23/JSPI PC3 - LPTIM1_ETR LPTIM3_CH1 SAI1_D1 - SPI2_MOSI - - - - OCTOSPIM_P1_IO6 - - SAI1_SD_A LPTIM2_ETR EVENTOUT
24 D24/JSPI PD1 - - - - - SPI2_SCK - - - FDCAN1_TX - - FMC_D3/FMC_
AD3
- - EVENTOUT

The processor has registers that control how each pin in each GPIO port is used. For each port there is a register, that says if each pin is an Input pin, an Output pin or is
is being used for an alternate function. There is than a couple of registers per port
that says if a pin is defined as using an Alternate function, which one? 0-15, which
is what this table shows.

Looks like you found the processor PDF files that defines this.
An easy way to figure out what processor pin is connected to which Arduino defined
IO pins, like D0, D1, ... Is to look in the Arduino boards install of it in the variants directory at the overlay file. So for example on my windows machine it is located at:
C:\Users\kurte\AppData\Local\Arduino15\packages\arduino\hardware\zephyr\0.52.0\variants\arduino_uno_q_stm32u585xx\arduino_uno_q_stm32u585xx.overlay.

At the section:

	zephyr,user {
		digital-pin-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>, /* D0 - PB7 */
				    <&gpiob 6 GPIO_ACTIVE_HIGH>, /* D1 - PB6 */
				    <&gpiob 3 GPIO_ACTIVE_HIGH>, /* D2 - PB3 */
				    <&gpiob 0 GPIO_ACTIVE_HIGH>, /* D3 - PB0 */
				    <&gpioa 12 GPIO_ACTIVE_HIGH>, /* D4 - PA12 */
				    <&gpioa 11 GPIO_ACTIVE_HIGH>, /* D5 - PA11 */
				    <&gpiob 1 GPIO_ACTIVE_HIGH>, /* D6 - PB1 */
				    <&gpiob 2 GPIO_ACTIVE_HIGH>, /* D7 - PB2 */
				    <&gpiob 4 GPIO_ACTIVE_HIGH>, /* D8 - PB4 */
				    <&gpiob 8 GPIO_ACTIVE_HIGH>, /* D9 - PB8 */
				    <&gpiob 9 GPIO_ACTIVE_HIGH>, /* D10 - PB9 */
				    <&gpiob 15 GPIO_ACTIVE_HIGH>, /* D11 - PB15 */
				    <&gpiob 14 GPIO_ACTIVE_HIGH>, /* D12 - PB14 */
				    <&gpiob 13 GPIO_ACTIVE_HIGH>, /* D13 - PB13 */

					/* ADCs */
				    <&gpioa 4 GPIO_ACTIVE_HIGH>, /* A0 - PA4 */
				    <&gpioa 5 GPIO_ACTIVE_HIGH>, /* A1 - PA5 */
				    <&gpioa 6 GPIO_ACTIVE_HIGH>, /* A2 - PA6 */
				    <&gpioa 7 GPIO_ACTIVE_HIGH>, /* A3 - PA7 */
				    <&gpioc 1 GPIO_ACTIVE_HIGH>, /* A4 - PC1 */
				    <&gpioc 0 GPIO_ACTIVE_HIGH>, /* A5 - PC0 */

				    <&gpiob 11 GPIO_ACTIVE_HIGH>,  /* D20 - PB11 */
				    <&gpiob 10 GPIO_ACTIVE_HIGH>,  /* D21 - PB10 */

				    <&gpioc 2 GPIO_ACTIVE_HIGH>,        /* JSPI */
				    <&gpioc 3 GPIO_ACTIVE_HIGH>,
				    <&gpiod 1 GPIO_ACTIVE_HIGH>,

				    <&gpioc 6 GPIO_ACTIVE_HIGH>,	/* JMISC */
				    <&gpiod 2 GPIO_ACTIVE_HIGH>,
				    <&gpioc 7 GPIO_ACTIVE_HIGH>,
				    <&gpioe 2 GPIO_ACTIVE_HIGH>,
				    <&gpioc 8 GPIO_ACTIVE_HIGH>,
				    <&gpioe 3 GPIO_ACTIVE_HIGH>,
				    <&gpioc 9 GPIO_ACTIVE_HIGH>,
				    <&gpioe 5 GPIO_ACTIVE_HIGH>,
				    <&gpioe 4 GPIO_ACTIVE_HIGH>,
				    <&gpioe 6 GPIO_ACTIVE_HIGH>,
				    <&gpioi 4 GPIO_ACTIVE_HIGH>,
				    <&gpioe 7 GPIO_ACTIVE_HIGH>,
				    <&gpioi 6 GPIO_ACTIVE_HIGH>,
				    <&gpioe 8 GPIO_ACTIVE_HIGH>,
				    <&gpioi 7 GPIO_ACTIVE_HIGH>,
				    <&gpiof 14 GPIO_ACTIVE_HIGH>,
				    <&gpiod 9 GPIO_ACTIVE_HIGH>,
				    <&gpiof 15 GPIO_ACTIVE_HIGH>,
				    <&gpioi 5 GPIO_ACTIVE_HIGH>,
				    <&gpioa 3 GPIO_ACTIVE_HIGH>,
				    <&gpiod 8 GPIO_ACTIVE_HIGH>,
				    <&gpioa 0 GPIO_ACTIVE_HIGH>,
				    <&gpioa 8 GPIO_ACTIVE_HIGH>,
				    <&gpioa 1 GPIO_ACTIVE_HIGH>,
				    <&gpioa 10 GPIO_ACTIVE_HIGH>,

				    <&gpioh 10 GPIO_ACTIVE_HIGH>,        /* LEDs */
				    <&gpioh 11 GPIO_ACTIVE_HIGH>,
				    <&gpioh 12 GPIO_ACTIVE_HIGH>,
				    <&gpioh 13 GPIO_ACTIVE_HIGH>,
				    <&gpioh 14 GPIO_ACTIVE_HIGH>,
				    <&gpioh 15 GPIO_ACTIVE_HIGH>,

				    <&gpiof 0 GPIO_ACTIVE_HIGH>,        /* LED matrix */
				    <&gpiof 1 GPIO_ACTIVE_HIGH>,
				    <&gpiof 2 GPIO_ACTIVE_HIGH>,
				    <&gpiof 3 GPIO_ACTIVE_HIGH>,
				    <&gpiof 4 GPIO_ACTIVE_HIGH>,
				    <&gpiof 5 GPIO_ACTIVE_HIGH>,
				    <&gpiof 6 GPIO_ACTIVE_HIGH>,
				    <&gpiof 7 GPIO_ACTIVE_HIGH>,
				    <&gpiof 8 GPIO_ACTIVE_HIGH>,
				    <&gpiof 9 GPIO_ACTIVE_HIGH>,
				    <&gpiof 10 GPIO_ACTIVE_HIGH>,
				    <&gpiog 13 GPIO_ACTIVE_HIGH>,       /* Internal SPI RDY */
				    <&gpioa 2 GPIO_ACTIVE_HIGH>,        /* Analog switch for VREF */
				    <&gpioh 3 GPIO_ACTIVE_HIGH>;        /* BOOT0 */

And of course you can always look at the schematic
IMOLA_DVTB_WNC_BB_20251001
Like at page 5

2 Likes

Do you have schematic for STM32U585 MCU of the UNOQ board? Is this MCU of 169-pin "ballout" package?

It is available for download from the "DOWNLOADABLE RESOURCES" section of the UNO Q's documentation page:
https://docs.arduino.cc/hardware/uno-q/

The part number is STM32U585AII6TR:

Parameters

Package Name UFBGA 169 7x7x0.6 P 0.5 mm
2 Likes

I am now confirmed on the pacakge type of STM32U585 used in UNOQ Board. It is: Package Name UFBGA 169 7x7x0.6 P 0.5 mm

A post was split to a new topic: How to reference LED matrix pins?