Skip to content

Commit 890af33

Browse files
author
Simon Burkhardt
committed
fixed links + stm32cubemx ide
1 parent c8da681 commit 890af33

File tree

3 files changed

+100
-5
lines changed

3 files changed

+100
-5
lines changed

STM32 Tutorial 000 - Introduction/README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ I will point out sources of information and I will show how to use this informat
1414
### IDE
1515

1616
The following document gives an overview on the available IDEs and tools.
17-
In my tutorials I am going to use Keil µVision 5.
17+
In my tutorials I am going to use Keil µVision 5 and STM32CubeMX IDE.
1818

1919
- Getting started with STM32 Nucleo board software development tools (User Manual) [UM1727](https://www.st.com/content/ccc/resource/technical/document/user_manual/1b/03/1b/b4/88/20/4e/cd/DM00105928.pdf/files/DM00105928.pdf/jcr:content/translations/en.DM00105928.pdf)
2020

@@ -23,6 +23,12 @@ In my tutorials I am going to use Keil µVision 5.
2323
- **[STM32CubeMX Download](https://www.st.com/en/development-tools/stm32cubemx.html)**
2424
- User Manual STM32CubeMX for STM32 configuration and initialization C code generation **[UM1718](https://www.st.com/content/ccc/resource/technical/document/user_manual/10/c5/1a/43/3a/70/43/7d/DM00104712.pdf/files/DM00104712.pdf/jcr:content/translations/en.DM00104712.pdf)** (pdf)
2525

26+
#### STM32CubeMX IDE
27+
28+
Uses the open source `gcc-arm-none-eabi` compiler. Has the above STM32CubeMX graphical user interface integrated.
29+
30+
- **[STM32CubeMX IDE Download](https://www.st.com/en/development-tools/stm32cubemx.html#overview)**
31+
- (User Manual STM32CubeMX for STM32 configuration and initialization C code generation **[UM1718](https://www.st.com/content/ccc/resource/technical/document/user_manual/10/c5/1a/43/3a/70/43/7d/DM00104712.pdf/files/DM00104712.pdf/jcr:content/translations/en.DM00104712.pdf)** (pdf))
2632

2733
#### Keil µVision
2834

@@ -34,7 +40,7 @@ In my tutorials I will use Keil µVision 5.
3440

3541
#### System Workbench for MCU by AC6 (Open Source)
3642

37-
Uses the open source `gcc-arm-none-eabi` compiler.
43+
Uses the open source `gcc-arm-none-eabi` compiler. (I heard that it is soon to be outdated or does not support newer MCUs anymore.)
3844

3945
- STMicroelectronics [AC6](https://www.st.com/content/st_com/en/partner/partner-program/partnerpage/AC6.html)
4046
+ [ac6-tools](https://www.ac6-tools.com/content.php/content_SW4MCU/lang_en_GB.xphp)
@@ -56,7 +62,7 @@ The STM32CubeMX Software has all the Application Notes and User Manuals related
5662

5763
Some peripheral drivers or software libraries may have the documentation also in the configuration menu.
5864

59-
![STM32CubeMX Help Menu](images/CubeMX_Docs_Periph.png)
65+
![STM32CubeMX Help Menu](images/CubeMX_Docs_periph.png)
6066

6167

6268
#### ARM
@@ -71,15 +77,14 @@ It is an engineers job to be able to read manufacturer documentation. This is wh
7177
Please note that Keil µVision uses a **Package Manager** for Hardware specific drivers and software.
7278

7379
- [arm Developer Documentation](https://developer.arm.com/docs)
74-
- **[arm Infocenter](http://infocenter.arm.com/help/index.jsp)**
80+
- **[developer.arm.com](https://developer.arm.com/documentation/)** ( previously: [arm Infocenter](http://infocenter.arm.com/help/index.jsp) )
7581

7682
##### Architecture Overview
7783

7884
ARM Cortex<span><sup>&trade;</sup></span>-M stands for Microcontroller architecture. There are different profiles, hence M0, M1, M3, M4 and M7.
7985

8086

8187
- Cortex<span><sup>&trade;</sup></span>-M0 [Generic User Guide](http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/DUI0497A_cortex_m0_r0p0_generic_ug.pdf) (pdf) (contains Instruction Set information)
82-
- Cortex<span><sup>&trade;</sup></span>-M1 Generic User Guide (reference needed)
8388
- Cortex<span><sup>&trade;</sup></span>-M3 [Generic User Guide](http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/DUI0552A_cortex_m3_dgug.pdf) (pdf) (contains Instruction Set information)
8489
- Cortex<span><sup>&trade;</sup></span>-M4 [Generic User Guide](http://infocenter.arm.com/help/topic/com.arm.doc.dui0553b/DUI0553.pdf) (pdf) (contains Instruction Set information)
8590
- Cortex<span><sup>&trade;</sup></span>-M7 [Generic User Guide](http://infocenter.arm.com/help/topic/com.arm.doc.dui0646a/DUI0646A_cortex_m7_dgug.pdf) (pdf) (contains Instruction Set information)

STM32 Tutorial 002 - UART Communication/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ First, you need to include the standard IO C library.
105105

106106
Next, you redirect the `printf` to the `USART2` interface using the just discovered `HAL_UART_Transmit` function.
107107

108+
**Code for Keil µVision**:
109+
108110
```c
109111
/* Private user code ---------------------------------------------------------*/
110112
/* USER CODE BEGIN 0 */
@@ -131,10 +133,48 @@ int ferror(FILE *f){
131133
/* USER CODE END 0 */
132134
```
133135
136+
**Code for `gcc-arm-none-eabi`** (STM32CubeMX IDE and SW4STM32):
137+
138+
```c
139+
/* Private user code ---------------------------------------------------------*/
140+
/* USER CODE BEGIN PFP */
141+
/**
142+
* @see https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32F401RE-Nucleo/Examples/UART/UART_Printf/Src/main.c
143+
*/
144+
#ifdef __GNUC__
145+
/* With GCC, small printf (option LD Linker->Libraries->Small printf
146+
set to 'Yes') calls __io_putchar() */
147+
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
148+
#else
149+
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
150+
#endif /* __GNUC__ */
151+
/* USER CODE END PFP */
152+
```
153+
154+
```c
155+
/* USER CODE BEGIN 4 */
156+
/**
157+
* @brief Retargets the C library printf function to the USART.
158+
* @param None
159+
* @retval None
160+
* @see https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32F401RE-Nucleo/Examples/UART/UART_Printf/Src/main.c
161+
*/
162+
PUTCHAR_PROTOTYPE {
163+
/* Place your implementation of fputc here */
164+
/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
165+
HAL_UART_Transmit(&huart3, (uint8_t *) &ch, 1, 1);
166+
167+
return ch;
168+
}
169+
/* USER CODE END 4 */
170+
```
171+
172+
134173
Further reading:
135174

136175
- _"How printf to specific USART?"_ [community.arm.com](https://community.arm.com/developer/tools-software/tools/f/keil-forum/34791/how-printf-to-specific-usart)
137176
- _"STM32 printf() redirect"_ [stackoverflow.com](https://stackoverflow.com/questions/45535126/stm32-printf-redirect)
177+
- official example code [github.com/STMicroelectronics](https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32F401RE-Nucleo/Examples/UART/UART_Printf/Src/main.c)
138178

139179
Now you can simply use the `printf` function from your main code as you like.
140180
For example:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
3+
### Includes
4+
5+
```c
6+
/* USER CODE BEGIN Includes */
7+
#include <stdio.h> // printf
8+
/* USER CODE END Includes */
9+
```
10+
11+
### Private Function Prototypes
12+
13+
```c
14+
/* USER CODE BEGIN PFP */
15+
/**
16+
* @see https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32F401RE-Nucleo/Examples/UART/UART_Printf/Src/main.c
17+
*/
18+
#ifdef __GNUC__
19+
/* With GCC, small printf (option LD Linker->Libraries->Small printf
20+
set to 'Yes') calls __io_putchar() */
21+
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
22+
#else
23+
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
24+
#endif /* __GNUC__ */
25+
/* USER CODE END PFP */
26+
```
27+
28+
29+
### Implementation
30+
31+
(end of file)
32+
33+
```c
34+
/* USER CODE BEGIN 4 */
35+
/**
36+
* @brief Retargets the C library printf function to the USART.
37+
* @param None
38+
* @retval None
39+
* @see https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32F401RE-Nucleo/Examples/UART/UART_Printf/Src/main.c
40+
*/
41+
PUTCHAR_PROTOTYPE {
42+
/* Place your implementation of fputc here */
43+
/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
44+
HAL_UART_Transmit(&huart3, (uint8_t *) &ch, 1, 1);
45+
46+
return ch;
47+
}
48+
/* USER CODE END 4 */
49+
```
50+

0 commit comments

Comments
 (0)