1.. zephyr:board:: stm32f3_disco
2
3Overview
4********
5
6The STM32F3DISCOVERY Discovery kit features an ARM Cortex-M4 based STM32F303VC
7MCU with everything required for beginners and experienced users to get
8started quickly. Here are some highlights of the STM32F3DISCOVERY board:
9
10- STM32 microcontroller in LQFP100 package
11- Extension header for all LQFP100 I/Os for quick connection to prototyping
12  board and easy probing
13- On-board, ST-LINK/V2 for PCB version A or B or ST-LINK/V2-B for PCB version
14  C and newer, debugger/programmer with SWD connector
15- Board power supply: through USB bus or from an external 3 V or 5 V supply
16  voltage
17- External application power supply: 3 V and 5 V
18
19- Ten LEDs:
20
21       - 3.3 V power on (LD1)
22       - USB communication (LD2)
23       - Eight user LEDs: red (LD3/LD10), blue (LD4/LD9), orange (LD5/LD9)
24         and green (LD6/LD7)
25
26- Two push-buttons: USER and RESET
27- USB USER with Mini-B connector
28- L3GD20 or I3G4250D, ST MEMS motion sensor, 3-axis digital output gyroscope
29- LSM303DLHC or LSM303AGR, ST MEMS system-in-package featuring a 3D digital linear
30  acceleration sensor and a 3D digital magnetic sensor;
31
32.. HINT::
33   Recent PCB revisions (E and newer) are shipped with I3G4250D and LSM303AGR.
34
35More information about the board can be found at the
36`STM32F3DISCOVERY website`_.
37
38Hardware
39********
40
41STM32F3DISCOVERY Discovery kit provides the following hardware components:
42
43- STM32F303VCT6 in LQFP100 package
44- ARM |reg| 32-bit Cortex |reg| -M4 CPU with FPU
45- 72 MHz max CPU frequency
46- VDD from 2.0 V to 3.6 V
47- 256 KB Flash
48- 40 KB SRAM
49- Routine booster: 8 Kbytes of SRAM on instruction and data bus
50- GPIO with external interrupt capability
51- 4x12-bit ADC with 39 channels
52- 2x12-bit D/A converters
53- RTC
54- General Purpose Timers (13)
55- USART/UART (5)
56- I2C (2)
57- SPI (3)
58- CAN
59- USB 2.0 full speed interface
60- Infrared transmitter
61- DMA Controller
62
63More information about STM32F303VC can be found here:
64       - `STM32F303VC on www.st.com`_
65       - `STM32F303xC reference manual`_
66
67Supported Features
68==================
69
70The Zephyr stm32f3_disco board configuration supports the following hardware
71features:
72
73+-----------+------------+-------------------------------------+
74| Interface | Controller | Driver/Component                    |
75+===========+============+=====================================+
76| NVIC      | on-chip    | nested vector interrupt controller  |
77+-----------+------------+-------------------------------------+
78| UART      | on-chip    | serial port-polling;                |
79|           |            | serial port-interrupt               |
80+-----------+------------+-------------------------------------+
81| PINMUX    | on-chip    | pinmux                              |
82+-----------+------------+-------------------------------------+
83| GPIO      | on-chip    | gpio                                |
84+-----------+------------+-------------------------------------+
85| I2C       | on-chip    | i2c                                 |
86+-----------+------------+-------------------------------------+
87| SPI       | on-chip    | spi                                 |
88+-----------+------------+-------------------------------------+
89| USB       | on-chip    | USB device                          |
90+-----------+------------+-------------------------------------+
91| CAN       | on-chip    | CAN                                 |
92+-----------+------------+-------------------------------------+
93| IWDG      | on-chip    | Independent WatchDoG                |
94+-----------+------------+-------------------------------------+
95| PWM       | on-chip    | pwm                                 |
96+-----------+------------+-------------------------------------+
97| ADC       | on-chip    | adc                                 |
98+-----------+------------+-------------------------------------+
99| DAC       | on-chip    | dac                                 |
100+-----------+------------+-------------------------------------+
101| DMA       | on-chip    | Direct Memory Access                |
102+-----------+------------+-------------------------------------+
103| die-temp  | on-chip    | die temperature sensor              |
104+-----------+------------+-------------------------------------+
105| RTC       | on-chip    | rtc                                 |
106+-----------+------------+-------------------------------------+
107
108Other hardware features are not yet supported on Zephyr porting.
109
110The default configuration can be found in
111:zephyr_file:`boards/st/stm32f3_disco/stm32f3_disco_defconfig`
112
113
114Pin Mapping
115===========
116
117STM32F3DISCOVERY Discovery kit has 6 GPIO controllers. These controllers are
118responsible for pin muxing, input/output, pull-up, etc.
119
120For more details please refer to `STM32F3DISCOVERY board User Manual`_.
121
122Default Zephyr Peripheral Mapping:
123----------------------------------
124
125.. rst-class:: rst-columns
126
127- UART_1_TX : PC4
128- UART_1_RX : PC5
129- UART_2_TX : PA2
130- UART_2_RX : PA3
131- UART_4_TX : PC10
132- UART_4_RX : PC11
133- I2C1_SCL : PB6
134- I2C1_SDA : PB7
135- I2C2_SCL : PA9
136- I2C2_SDA : PA10
137- SPI1_NSS : PA4
138- SPI1_SCK : PA5
139- SPI1_MISO : PA6
140- SPI1_MOSI : PA7
141- SPI2_NSS : PB12
142- SPI2_SCK : PB13
143- SPI2_MISO : PB14
144- SPI2_MOSI : PB15
145- CAN1_RX : PD0
146- CAN1_TX : PD1
147- USB_DM : PA11
148- USB_DP : PA12
149- USER_PB : PA0
150- LD3 : PE9
151- LD4 : PE8
152- LD5 : PE10
153- LD6 : PE15
154- LD7 : PE11
155- LD8 : PE14
156- LD9 : PE12
157- LD10 : PE13
158- PWM : PA8
159- ADC1 : PA0
160- DAC1 : PA4
161
162System Clock
163============
164
165STM32F3DISCOVERY System Clock could be driven by internal or external
166oscillator, as well as main PLL clock. By default System clock is driven
167by PLL clock at 72 MHz, driven by 8 MHz MCO from the ST Link.
168
169Serial Port
170===========
171
172STM32F3DISCOVERY Discovery kit has up to 5 UARTs. The Zephyr console output
173is assigned to UART1. Default settings are 115200 8N1.
174
175I2C
176===
177
178STM32F3DISCOVERY has up to 2 I2Cs. I2C1 is connected to the LSM303DLHC and is
179an ultra-compact low-power system-in-package featuring a 3D digital linear
180acceleration sensor and a 3D digital magnetic sensor.
181
182USB
183===
184STM32F3DISCOVERY has a USB 2.0 full-speed device interface available through
185its mini USB connector (USB USER).
186
187CAN
188===
189The STM32F3DISCOVERY does not have an onboard CAN transceiver. In
190order to use the CAN bus on the this board, an external CAN bus
191transceiver must be connected to ``PD0`` (``CAN1_RX``) and ``PD1``
192(``CAN1_TX``).
193
194Programming and Debugging
195*************************
196
197STM32F3DISCOVERY Discovery kit includes a ST-LINK/V2 or ST-LINK/V2-B embedded
198debug tool interface.
199
200Applications for the ``stm32f3_disco`` board configuration can be built and
201flashed in the usual way (see :ref:`build_an_application` and
202:ref:`application_run` for more details).
203
204Flashing
205========
206
207The board is configured to be flashed using west `STM32CubeProgrammer`_ runner,
208so its :ref:`installation <stm32cubeprog-flash-host-tools>` is required.
209
210Alternatively, OpenOCD or JLink can also be used to flash the board using
211the ``--runner`` (or ``-r``) option:
212
213.. code-block:: console
214
215   $ west flash --runner openocd
216   $ west flash --runner jlink
217
218Flashing an application to STM32F3DISCOVERY
219-------------------------------------------
220
221First, connect the STM32F3DISCOVERY Discovery kit to your host computer using
222the USB port to prepare it for flashing. Then build and flash your application.
223
224Here is an example for the :zephyr:code-sample:`hello_world` application.
225
226.. zephyr-app-commands::
227   :zephyr-app: samples/hello_world
228   :board: stm32f3_disco
229   :goals: build flash
230
231
232In case you are using a recent PCB revision (E or newer), you have to use an
233adapted board definition:
234
235.. zephyr-app-commands::
236   :zephyr-app: samples/hello_world
237   :board: stm32f3_disco@E
238   :goals: build flash
239
240Run a serial host program to connect with your board. For PCB version A or B a
241TTL(3.3V) serial adapter is required. For PCB version C and newer a Virtual Com
242Port (VCP) is available on the  USB ST-LINK port.
243
244.. code-block:: console
245
246   $ minicom -D /dev/<tty device>
247
248Replace <tty_device> with the port where the STM32F3DISCOVERY board can be
249found. For example, under Linux, /dev/ttyUSB0.
250
251You should see the following message on the console:
252
253.. code-block:: console
254
255   Hello World! arm
256
257
258Debugging
259=========
260
261You can debug an application in the usual way.  Here is an example for the
262:zephyr:code-sample:`hello_world` application.
263
264.. zephyr-app-commands::
265   :zephyr-app: samples/hello_world
266   :board: stm32f3_disco
267   :goals: debug
268
269Again you have to use the adapted command for newer PCB revisions (E and newer):
270
271.. zephyr-app-commands::
272   :zephyr-app: samples/hello_world
273   :board: stm32f3_disco@E
274   :goals: debug
275
276.. _STM32F3DISCOVERY website:
277   https://www.st.com/en/evaluation-tools/stm32f3discovery.html
278
279.. _STM32F3DISCOVERY board User Manual:
280   https://www.st.com/resource/en/user_manual/dm00063382.pdf
281
282.. _STM32F303VC on www.st.com:
283   https://www.st.com/en/microcontrollers/stm32f303vc.html
284
285.. _STM32F303xC reference manual:
286   https://www.st.com/resource/en/reference_manual/dm00043574.pdf
287
288.. _STM32CubeProgrammer:
289   https://www.st.com/en/development-tools/stm32cubeprog.html
290