Skip to content

Commit aefb09e

Browse files
committed
add docs for stm8sblack
1 parent 35e9a58 commit aefb09e

10 files changed

Lines changed: 3649 additions & 139 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Unlocking a MCU by using Tools->Burn Bootloader in the Arduino IDE
1414

1515
### Changed
16-
- updated stm8flash to support more STM8 devices, the ST-Link/V2.1
16+
- completed I2C library, master transmit and master receive modes work
17+
- updated stm8flash to support more STM8 devices and the ST-Link/V2.1
1718
adapter found on STM8 Nucleo boards (and espstlink for Linux
1819
and OSX)
1920
- updated SDCC to version 3.8.0
108 KB
Loading

docs/hardware/stm8sblack-pinout.svg

Lines changed: 3379 additions & 0 deletions
Loading
105 KB
Loading

docs/hardware/stm8sblack.jpg

63 KB
Loading

docs/hardware/stm8sblack.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Generic STM8S105 breakout board
2+
3+
These simple breakout boards are are available on aliexpress and the other
4+
usual china web sites as "stm8s105k4t6 development board" for $1.60
5+
including shipping.
6+
7+
STM8S105K4T6 microcontroller, 16 KB Flash, 2 KB RAM, 1 KB EEPROM
8+
9+
- LED on PE5, active low.
10+
- external crystal 8MHz on PA1/PA2 or internal oszillator with 16 MHz
11+
- build-in serial bootloader
12+
- all I/O-pins accessible on header pins
13+
- mounting position for 4 pin SWIM connector (for ST-Link flash tool)
14+
- micro-USB connector for power supply only (data lines not connected)
15+
- 3.3V I/O voltage, regulator on board
16+
17+
18+
![Picture of the STM8S105K board](stm8sblack.jpg)
19+
20+
These boards are the bigger brother of the [STM8S103 breakout
21+
boards](stm8blue.md) with more I/O lines, more flash and more EEPROM. They
22+
are build around a CPU STM8S105K4T6 with 16MHz internal oscillator, 16kB
23+
flash, 2kB RAM, and 1kB EEPROM. The CPU includes a UART, SPI, I2C, PWM, 10
24+
bit ADC, 3 timer, and up to 25 I/O pins - almost like an Arduino Nano, but
25+
only half the flash space.
26+
27+
One (red) LED is connected to GPIO PE5. The push button is for reset. The
28+
CPU runs on 3.3V, a linear regulator is integrated on the board. The micro
29+
USB connector is only for (5V) power supply, the data lines are not
30+
connected.
31+
32+
All CPU pins are easily accessible on (optional) pin headers (pitch 2.54mm,
33+
perfect for breadboards).
34+
35+
36+
![Schematic of the STMS105 board](stm8sblack-schematic.jpg)
37+
38+
39+
## I2C not easy accessible
40+
41+
Unfortunatly, I2C is only available as an alternate pin function on this
42+
CPU. So far, there is no support in Sduino for handling the alternate
43+
function remapping bits in the option byte.
44+
45+
It is possible to modify these configuration registers via SWIM using a
46+
flash tool and stm8flash, but you are on your own there.
47+
48+
49+
50+
## Connection to the flash tool
51+
52+
I am using the ST-Link V2 compatible flash tool in the green plastic
53+
housing. The one in the metal housing uses a different pinout.
54+
55+
Connection to the flashtool:
56+
57+
Signal name |P3 on CPU board |Green flash tool|Metal flash tool
58+
------ |:-----: |:-----: |:-----:
59+
3V3 |1 |2 | 7
60+
SWIM |2 |5 | 5
61+
GND |3 |7 | 3
62+
NRST |4 |9 | 1
63+
64+
65+
66+
## Pin number mappings
67+
68+
The Arduino environment uses its own pin numbering scheme independent from
69+
the physical CPU pin numbers. Many Arduino sketches and libraries contain
70+
hard-coded assumptions about the number of pins with special functions.
71+
Ideally, all these numbers would be the same and all programs could be
72+
compiled without changes.
73+
74+
Unfortunatly, it turns out that a perfect mapping is not possible.
75+
76+
In the end I chose a simple geometric numbering for the module. The
77+
numbering is similar to a classic DIP package with the USB connector as the
78+
pin 1 marking. It starts with port pin PC3 and counting up from 0. This
79+
results in this mapping:
80+
81+
![STM8S105 breakout board pin mapping](stm8s_black_pinout.png)
82+
83+
84+
85+
sduino pin | STM8S105 CPU port pin
86+
---------- | ---------------------
87+
0-4 | PC3-PC7
88+
5-12 | PD0-PD7
89+
13,14 | PA1-PA2, connected to the 8 MHz crystal, weak output drivers
90+
16-21 | PB5-PB0 (reverse order, weak output drivers)
91+
22 | PE5, weak output driver
92+
23,24 | PC1-PC2, weak output drivers
93+
94+
- serial: 10,11
95+
- SPI: 2,3,4,22
96+
- I2C: 16,17 (has to be activated as an alternative function first)
97+
- Analog: 16-21
98+
- PWM: 0,1,5,7-9,23,24
99+
- LED: 22
100+
101+
pros of this approach:
102+
103+
- Easy and logical for use on a breadboard
104+
- Very clear and logical port pin ordering
105+
106+
cons of this approach:
107+
108+
- All functions use totally different pin numbers than Arduino
109+
110+
I am still not really happy with this mapping. Instead of simplifing things
111+
it only adds another layer of abstraction and confusion. To avoid this I
112+
added definitions for the regular CPU pin names like `PA1` and `PD2`. In the
113+
end, this notation seems to be a lot easier to me. I am open for suggestions
114+
for a better pin number mapping.
115+
116+
117+
The chosen pin mapping for the STM8S105K (possible alternate function in
118+
paratheses):
119+
120+
|Phys. STM8 pin|Name |Functions |Geometrical mapping|special funcion
121+
|---: |--- |--- | --- |---
122+
|2 |PA1 |(OscIn, no HS) |13 |
123+
|3 |PA2 |(OscOut, no HS) |14 |
124+
|8 |PF4 |Ain12 (not supported, no HS)|15 |
125+
|11 |PB5 |Ain5, [SDA], no HS |16 |Analog A0
126+
|12 |PB4 |Ain4, [SCL], no HS |17 |Analog A1
127+
|13 |PB3 |Ain3, no HS |18 |Analog A2
128+
|14 |PB2 |Ain2, no HS |19 |Analog A3
129+
|15 |PB1 |Ain1, no HS |20 |Analog A4
130+
|16 |PB0 |Ain0, no HS |21 |Analog A5
131+
|17 |PE5 |SPI_NSS, no HS |22 |LED
132+
|18 |PC1 |T1-1 |23 |PWM
133+
|19 |PC2 |T1-2 |24 |PWM
134+
|20 |PC3 |T1-3 |0 |PWM
135+
|21 |PC4 |T1-4 |1 |PWM
136+
|22 |PC5 |SCK |2 |
137+
|23 |PC6 |MOSI |3 |
138+
|24 |PC7 |MISO |4 |
139+
|25 |PD0 |T3-2 |5 |PWM
140+
|26 |PD1 |SWIM |6 |
141+
|27 |PD2 |T3-1 |7 |PWM
142+
|28 |PD3 |T2-2 |8 |PWM
143+
|29 |PD4 |T2-1/Beep |9 |PWM
144+
|30 |PD5 |TX |10 |
145+
|31 |PD6 |RX |11 |
146+
|32 |PD7 |TLI |12 |
147+
148+
149+
150+
## Special pins
151+
152+
Most pins on the right side are weaker than the other pins. Try avoiding
153+
these pins for LEDs and other higher current applications: D13-D22 (PA1/PA2,
154+
PF4, PB5-PB0, PE5)

mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ nav:
2929
- Hardware:
3030
- Flash tool: hardware/flashtool.md
3131
# - List of supported boards: hardware.md
32-
- 'Generic STM8S103 breakout board (stm8blue)': hardware/stm8blue.md
32+
- 'Generic STM8S103F3 breakout board (stm8blue)': hardware/stm8blue.md
3333
- 'ESP14 Wifi board (STM8S003F3P6)': hardware/esp14.md
3434
- 'W1209 thermostat board (STM8S003F3P6)': 'hardware/w1209-thermostat.md'
35-
- 'STM8S105Discovery: Evaluation board made my ST': hardware/stm8sdiscovery.md
35+
- 'Generic STM8S105K4 breakout board (stm8sblack)': hardware/stm8sblack.md
36+
- 'STM8S105Discovery evaluation board made by ST (STM8S105C6)': hardware/stm8sdiscovery.md
3637
- 'sduino Uno (STM8S105K6)': https://github.com/roybaer/sduino_uno
3738
- 'sduino MB (STM8S208MB), inspired by Arduino Mega': https://github.com/roybaer/sduino_mb
3839
- Developer Guide:

0 commit comments

Comments
 (0)