1.. _nucleo_g431rb_board:
2
3ST Nucleo G431RB
4################
5
6Overview
7********
8
9The Nucleo G431RB board features an ARM Cortex-M4 based STM32G431RB MCU
10with a wide range of connectivity support and configurations. Here are
11some highlights of the Nucleo G431RB board:
12
13- STM32 microcontroller in LQFP64 package
14- Arduino Uno V3 connectivity
15- On-board ST-LINK/V3E debugger/programmer with SWD connector
16- Flexible board power supply:
17
18  - USB VBUS or external source(3.3V, 5V, 7 - 12V)
19  - Power management access point
20
21- Three LEDs: USB communication (LD1), power LED (LD3), user LED (LD2)
22- Two push-buttons: RESET and USER
23
24.. image:: img/nucleo_g431rb.jpg
25  :align: center
26  :alt: Nucleo G431RB
27
28More information about the board can be found at the `Nucleo G431RB website`_.
29
30Hardware
31********
32
33The STM32G431RB SoC provides the following hardware IPs:
34
35- Ultra-low-power with FlexPowerControl (down to 28 nA Standby mode and 84
36  |micro| A/MHz run mode)
37- Core: ARM |reg| 32-bit Cortex |reg| -M4 CPU with FPU, frequency up to 170 MHz
38- Clock Sources:
39
40  - 4 to 48 MHz crystal oscillator (HSE)
41  - 32 kHz crystal oscillator for RTC (LSE)
42  - Internal 16 MHz factory-trimmed RC ( |plusminus| 1%)
43  - Internal low-power 32 kHz RC ( |plusminus| 5%)
44  - 2 PLLs for system clock, USB, audio, ADC
45
46- RTC with HW calendar, alarms and calibration
47- 14x timers:
48
49  - 1x 32-bit timer and 2x 16-bit timers with up to four IC/OC/PWM or pulse counter and quadrature (incremental) encoder input
50  - 2x 16-bit 8-channel advanced motor control timers, with up to 8x PWM channels, dead time generation and emergency stop
51  - 1x 16-bit timer with 2x IC/OCs, one OCN/PWM, dead time generation and emergency stop
52  - 2x 16-bit timers with IC/OC/OCN/PWM, dead time generation and emergency stop
53  - 2x watchdog timers (independent, window)
54  - 2x 16-bit basic timers
55  - SysTick timer
56  - 1x low-power timer
57
58- Up to 86 fast I/Os, most 5 V-tolerant
59- Memories
60
61  - Up to 128 KB single bank Flash, proprietary code readout protection
62  - Up to 22 KB of SRAM including 16 KB with hardware parity check
63
64- Rich analog peripherals (independent supply)
65
66  - 2x 12-bit ADC 5 MSPS, up to 16-bit with hardware oversampling, 200
67    |micro| A/MSPS
68  - 4x 12-bit DAC, low-power sample and hold
69  - 3x operational amplifiers with built-in PGA
70  - 4x ultra-fast rail-to-rail analog comparators
71
72- 16x communication interfaces
73
74  - 1 x FDCAN controller supporting flexible data rate
75  - 3x I2C FM+(1 Mbit/s), SMBus/PMBus
76  - 4x USARTs (ISO 7816, LIN, IrDA, modem)
77  - 1x LPUART
78  - 3x SPIs (2x with multiplexed half duplex I2S interface)
79  - 1x SAI (serial audio interface)
80  - USB 2.0 full-speed interface with LPM and BCD support
81  - IRTIM (Infrared interface)
82  - USB Type-C™ /USB power delivery controller (UCPD)
83
84- 12-channel DMA controller
85- True random number generator (RNG)
86- CRC calculation unit, 96-bit unique ID
87- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell*
88
89
90More information about STM32G431RB can be found here:
91
92- `STM32G431RB on www.st.com`_
93- `STM32G4 reference manual`_
94
95Supported Features
96==================
97
98The Zephyr nucleo_g431rb board configuration supports the following hardware features:
99
100+-----------+------------+-------------------------------------+
101| Interface | Controller | Driver/Component                    |
102+===========+============+=====================================+
103| NVIC      | on-chip    | nested vector interrupt controller  |
104+-----------+------------+-------------------------------------+
105| UART      | on-chip    | serial port-polling;                |
106|           |            | serial port-interrupt               |
107+-----------+------------+-------------------------------------+
108| PINMUX    | on-chip    | pinmux                              |
109+-----------+------------+-------------------------------------+
110| GPIO      | on-chip    | gpio                                |
111+-----------+------------+-------------------------------------+
112| I2C       | on-chip    | i2c                                 |
113+-----------+------------+-------------------------------------+
114| PWM       | on-chip    | pwm                                 |
115+-----------+------------+-------------------------------------+
116| DAC       | on-chip    | dac                                 |
117+-----------+------------+-------------------------------------+
118| COUNTER   | on-chip    | rtc                                 |
119+-----------+------------+-------------------------------------+
120| SPI       | on-chip    | spi                                 |
121+-----------+------------+-------------------------------------+
122| RNG       | on-chip    | rng                                 |
123+-----------+------------+-------------------------------------+
124
125Other hardware features are not yet supported on this Zephyr port.
126
127The default configuration can be found in the defconfig file:
128``boards/arm/nucleo_g431rb/nucleo_g431rb_defconfig``
129
130
131Connections and IOs
132===================
133
134Nucleo G431RB Board has 6 GPIO controllers. These controllers are responsible for pin muxing,
135input/output, pull-up, etc.
136
137For more details please refer to `STM32G4 Nucleo-64 board User Manual`_.
138
139Default Zephyr Peripheral Mapping:
140----------------------------------
141
142.. rst-class:: rst-columns
143
144- UART_1_TX : PC4
145- UART_1_RX : PC5
146- LPUART_1_TX : PA2
147- LPUART_1_RX : PA3
148- I2C_1_SCL : PB8
149- I2C_1_SDA : PB9
150- SPI_1_NSS : PB6
151- SPI_1_SCK : PA5
152- SPI_1_MISO : PA6
153- SPI_1_MOSI : PA7
154- SPI_2_NSS : PB12
155- SPI_2_SCK : PB13
156- SPI_2_MISO : PB14
157- SPI_2_MOSI : PB15
158- SPI_3_NSS : PA15
159- SPI_3_SCK : PC10
160- SPI_3_MISO : PC11
161- SPI_3_MOSI : PC12
162- PWM_3_CH1 : PB4
163- USER_PB : PC13
164- LD2 : PA5
165- DAC1_OUT1 : PA4
166
167System Clock
168------------
169
170Nucleo G431RB System Clock could be driven by internal or external oscillator,
171as well as main PLL clock. By default System clock is driven by PLL clock at 150MHz,
172driven by 16MHz high speed internal oscillator. The clock can be boosted to 170MHz if boost mode
173is selected.
174
175Serial Port
176-----------
177
178Nucleo G431RB board has 3 U(S)ARTs and one LPUART. The Zephyr console output is assigned to LPUART1.
179Default settings are 115200 8N1.
180
181Please note that LPUART1 baudrate is limited to 9600 if the MCU is clocked by LSE (32.768 kHz) in
182low power mode.
183
184Programming and Debugging
185*************************
186
187Applications for the ``nucleo_g431rb`` board configuration can be built and
188flashed in the usual way (see :ref:`build_an_application` and
189:ref:`application_run` for more details).
190
191Flashing
192========
193
194Nucleo G431RB board includes an ST-LINK/V3E embedded debug tool interface.
195
196This interface is not yet supported by the openocd version included in the Zephyr SDK.
197
198Instead, support can be enabled on pyocd by adding "pack" support with
199the following pyocd command:
200
201.. code-block:: console
202
203   $ pyocd pack --update
204   $ pyocd pack --install stm32g431rb
205
206Note:
207To manually enable the openocd interface, You can still update, compile and install
208a 'local' openocd from the official openocd repo http://openocd.zylin.com .
209Then run the following openocd command where the '/usr/local/bin/openocd'is your path
210for the freshly installed openocd, given by "$ which openocd" :
211
212.. code-block:: console
213
214   $ west flash --openocd /usr/local/bin/openocd
215
216Flashing an application to Nucleo G431RB
217----------------------------------------
218
219Connect the Nucleo G431RB to your host computer using the USB port,
220then run a serial host program to connect with your Nucleo board.
221
222.. code-block:: console
223
224   $ minicom -D /dev/ttyACM0
225
226Now build and flash an application. Here is an example for
227:ref:`hello_world`.
228
229.. zephyr-app-commands::
230   :zephyr-app: samples/hello_world
231   :board: nucleo_g431rb
232   :goals: build flash
233
234You should see the following message on the console:
235
236.. code-block:: console
237
238   $ Hello World! arm
239
240
241Debugging
242=========
243
244You can debug an application in the usual way.  Here is an example for the
245:ref:`hello_world` application.
246
247.. zephyr-app-commands::
248   :zephyr-app: samples/hello_world
249   :board: nucleo_g431rb
250   :maybe-skip-config:
251   :goals: debug
252
253.. _Nucleo G431RB website:
254   https://www.st.com/en/evaluation-tools/nucleo-g431rb.html
255
256.. _STM32G4 Nucleo-64 board User Manual:
257   https://www.st.com/resource/en/user_manual/dm00556337.pdf
258
259.. _STM32G431RB on www.st.com:
260   https://www.st.com/en/microcontrollers/stm32g431rb.html
261
262.. _STM32G4 reference manual:
263   https://www.st.com/resource/en/reference_manual/dm00355726.pdf
264