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