stm32l476rg with SN65HVD11P IC Transciever and AMT21 Encoder
Hi all,
I'm working on a project involving UART communication over RS-485 between an STM32 Nucleo board and a rotary encoder. I'd appreciate any advice or insights on whether my hardware and firmware setup looks correct, and what to check next to ensure reliable communication.
Board: STM32 Nucleo-L476RG
Encoder: 6-pin rotary encoder with the following pinout:
-
Pin 1: 5V
-
Pin 2: B
-
Pin 3: A
-
Pin 4: GND
-
Pin 5: MODE
-
Pin 6: MCLR
RS-485 Transceiver: MAX485-compatible module
-
RO (Receiver Out) → PA10 (USART1_RX)
-
DI (Driver In) → PA9 (USART1_TX)
-
RE (Receiver Enable) → PB3
-
DE (Driver Enable) → PB4
-
VCC: 3.3V (from Nucleo 3.3V)
-
GND: common with Nucleo and encoder
- A ---> Encoder Pin A
- B ---> Enocder Pin B
PC Interface:
-
I'm using a USB cable from the laptop to the Nucleo, which powers the board and also uploads code.
-
USART2 is used for debug printouts via USB virtual COM port (seen in PuTTY).
-
USART1 is used for RS-485 communication
I believe my issue is in the software. How do I get communication?
Here are the datasheets:
Encoder: https://www.sameskydevices.com/product/resource/amt21.pdf
