-
Notifications
You must be signed in to change notification settings - Fork 51
/
scraps.txt
224 lines (117 loc) · 10.1 KB
/
scraps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
### Bonus: Reading
If STM32CubeMX asks you what to do when opening `.ioc` files, always pick `Migrate`:
![Alt text](resources/images/mig.png)
## How to use this guide
Click "Download ZIP" on the top right corner to get lesson files, then just follow along on this webpage.
![Alt text](resources/images/dl.png)
We don't actually have to put anything else in it right now, you can leave the `linear_buf.c` empty as well for the time being.
Put it between `USER CODE` comment blocks, in this case the PV section:
We'll focus more on the interrupt part in order to show you h
External interrupt is useful because you don't have to waste CPU time polling every pin you're using in a loop. Instead a callback function is executed every time the pin changes. This is particularly useful if you're designing a button interface
HAL_GPIO_TogglePin(USER_LED_GPIO_Port, USER_LED_Pin);
HAL_UART_Transmit(&huart1, msg, 12, 100);
// printf("hello world\n");
HAL_Delay(200);
You ask the peripheral to do something, and the peripheral will let you know when its finished via interrupt.
dramatically in I/O heavy situations
## Headers
For this and subsequent lessons you do need to solder on the headers that came with the board, so that we can connect external components to it. It's a pretty easy job, and if you don't have the tools, try your local hackerspace or universities.
![Alt text](resources/headers.jpg)
Since we're using the 8MHz external crystal and we want to run the chip at max clock rate of 48MHz, we need to enlist the help of the PLL. Short for Phase Locked Loop, it can multiply a clock signal to a higher frequency.
We want to run the chip at max frequency of 48MHz, and the HSE is only 8MHz.
So we're using the 8MHz external crystal on the dev board, and the max clock frequency of the chip is 48MHz
Remember we were using the external clock from the 8MHz crystal on the dev board? That's why we selected HSE on the first mux on the yellow path.
At the first mux along the yellow path (PLL Source Mux) we select what clock signal goes into the PLL, as we're using the external 8MHz crystal we
Check the email and download the software from the link inside.
In this introductory lesson I will give a brief description about STM32 and what you need for this tutorial, and we'll start coding properly from next lesson.
try open it up and see if it works:
![Alt text](resources/cubehome.png)
Feel free to close it as we'll come back to this later, for now
If everything works, congrats! You can move on to the next software now. [**OPTIOINAL**] However if you're not hurry we can try something else: You might notice there is already something in the flash memory, let's erase it. Click on the eraser button then confirm:
![Alt text](resources/eraseconfirm.png)
After a few seconds the whole chip will be erased and everything back to 0xFF, which is how it comes out of the factory:
![Alt text](resources/erased.png)
Again, this is not strictly necessary, since the chip gets erased every time you upload a new firmware anyway, but it's nice to get familiar with the tool, and there are more in the "Target" menu that you can play with.
anyway, that's the first one done, good job!
All the GPIO pins starts with "P" like PA1, PA2... etc.
* Every single pin on this STM32 has been broken out on the header, even though some are already used on the board itself. It's not necessarily a bad thing, you just have to beware of it. Namely PF0 and PF1 has a crystal oscillator on it, PA4 has an LED, and NRST has a button.
All STM32 have internal clocks as well, but they're generally less accurate.
Each GPIO pin can be used for peripheral functions as well like UART and I2C, but we'll worry about that later.
Note that there are multiple packages in the same F030 family,
also install the driver for the ST-LINK programmer you just bought. You can use it to
All the STM32 chips have long names, luckily it's pretty easy to make sense of them and get a general feeling of its capability, here's an example:
If you buy one programmer and one board the total cost would be less than 5 dollars including shipping, although I do recommend getting 2 of each so you have spares. And even then it's less than 10 dollars.
in order to ease the transition from Arduino to a lower level environment
# STM32F042K6T6
Now to break it down:
### STM32
Brand name, always there.
### F0
Product family. The first letter is product type, F is standard, L is Low Power, H for High Performance.
The number indicates what ARM processor core is it using:
| STM32 Series | ARM Core |
|--------------|--------------|
| F7, H7 | Cortex-M7F |
| F4, F3, L4 | Cortex-M4F |
| F2, F1, L1 | Cortex-M3 |
| L0 | Cortex-M0+ |
| F0 | Cortex-M0 |
Generally speaking, the higher the number, the better the performance and the variety of peripherals, but also more expensive. F0 is more than adequate for most projects.
http://www.st.com/content/st_com/en/about/media-center/press-item.html/t3934.html
### 42
Specific Features. Within the same family, the higher the number, the more feature-packed it will be. For example F072 will have much more peripherals than F031. Look at the datasheet for details.
### K
Pin count. K is 32 pins, C is 48 pins, R is 64 pins, etc.
### 6
Flash memory size. 6 is 32KB, 8 is 64KB, B is 128KB, etc.
### T
Package type. T is QFP, P is TSSOP, etc.
### 6
As you can see, the STM32 blows the ol' Arduino out of the water in just about every single aspect.
One other advantage is the compatibility and upgradability. There are **hundreds** of STM32 variants to choose from, and they mostly have the same pinout for a given package type. That means should you find the chip sufficient, you can simply replace it with a more powerful one without changing the circuit design
And let's not forget this is only one of the entry level STM32 chips we're talking about here,
No doubt a lot Arduino tinkerers have entertained the thought of going pro, however
As a result, if you want to develop your own product or something else it makes more sense to use a STM32 than aging old arduino.
It's all well and good, and most people are perfectly content with that. However, for some there are still reasons to dive deeper into the world of embedded systems. It could be career opportunities, performance issues, or just pure interest about how it all works below the surface.
Whatever it is, if you look at the actual chip on most Arduinos, you'll find an ATmega328P, an aging decade old 8-bit chip with tiny amount of system memory, limited peripherals, and a leisurely clock speed of 16MHz. As a result, in commercial situations 8-bitters like those have been mostly relegated to cost-sensitive applications like cheap toys. And the world has moved on to 32-bit microcontrollers.
It is sufficient for most hobby projects that simply doesn't need that much processing power, however, in professional situations that do, it is rather archaic and inadequate. As a result, 8-bit microcontrollers have been mostly relegated to cost-sensitive applications like cheap toys
And when it comes to embedded processors, it's all about ARM. They don't produce the chips themselves, instead they design the processor architectures and license them out to other companies where they can make further customizations and have them made
It's all well and good, and most people are perfectly content with that. However, for some there are reasons to dive deeper into the world of embedded systems. It could be from interest
and positively slow clock speed of 16MHz
Arduino is more of a gateway drug to embedded systems, and they
All in all, there is a whole different world underneath
some hooked and wants to learn more
arduino is not enough
Faster
Cheaper
Future proof, product family
more professional
debugging support
Now there are many good reasons to stay inside the Arduino ecosystem. After all, it kickstarted the "maker" revolution in the first place. Its consistent hardware, easy to use IDE, and most important of all, the extensive community support meant more people could start creating what want, and the abstraction layer meant that they don't have to worry about the nitty-gritty of pouring over datasheets and manually configuring peripherals.
Now there are many good reasons to stay inside the Arduino ecosystem. After all, it kickstarted the "maker" revolution in the first place. Its consistent hardware, simple IDE, and the extensive community support meant it's easier than ever for people to start creating what they want, and the abstraction layer meant that they don't have to worry about the nitty-gritty of what's actually happening at a lower level like manually configuring peripherals.
We'll take a look at the differences between Arduino and STM32,
If so, this guide is specifically designed with you in mind! We're going to
A big problem I found transitioning from Arduino to STM32
This guide is designed to be as detailed and as easy to follow as possible, that means:
* Using free and readily available software
* $5 worth of hardware (dev board and pr)
# STM32 the easy way
A step-by-step tutorial on getting started with STM32 development
## Purpose
Do you already have some experience with Arduino, and wanting to step up the game into proper ARM embedded system developments?
This guide is for people who already have some experience with Arduino, and wanting to step up the game into proper ARM embedded system developments.
This tutorial is designed to be detailed and easy to follow. The software we're using will be free and easy to install, and the STM32 board and programmer together will only cost $5(!) including shipping.
Note that this is not meant to be a comprehensive guide that touches on every aspects of STM32, instead it aims to get
provides a number of detailed and basic examples and
## how to use this guide
## why STM32
comparison
nodebugging
## STM32 parts naming conventions
## ..
blink
read button
uart tx
uart rx
uart rx with interrupt
spi sd card