Skip to content

Commit 08e2733

Browse files
committed
full reorganization and big rewrite of the website
1 parent 98ffd82 commit 08e2733

24 files changed

Lines changed: 981 additions & 645 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
Getting started on the STM8 CPU the easy way by using an Arduino-like
44
programming API.
55

6-
This project is based on free tools that are available for Linux, MacOS, and
7-
Windows: SDCC, make, and stm8flash. Since it's based on the SDCC Small
8-
Devices compiler, I called it "Small Devices -uino" or "Small-duino".
9-
10-
It fully integrates with the Arduino IDE or can be used
6+
It fully integrates with the Arduino IDE or it can be used
117
independently (GUI-less) with very easy Makefiles based on the amazing
128
[Arduino.mk makefile](https://github.com/sudar/Arduino-Makefile) by
139
[Sudar](http://sudarmuthu.com>).
1410

11+
This project is based on free tools that are available for Linux, MacOS, and
12+
Windows: SDCC, make, and stm8flash. Since it's based on the SDCC Small
13+
Devices C compiler, I called it "Small Devices -uino" or "Small-duino".
14+
1515
This project is not supposed to be “better than Arduino”. It’s purpose
1616
is to give you a head start into a different CPU architecture if you happen
1717
to have a professional need or a private desire for it.

docs/about.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,24 @@ powerful and provides an relativly easy migration path towards the STM32 CPU
1313
series in case a project outgrows the capabilities of the 8-bit STM8 series.
1414
But using that library is not very intuitive and still requires a fairly
1515
detailed knowledge of the CPU internals. [compiling the SPL with
16-
SDCC](spl.md)
16+
SDCC](developer/spl.md)
17+
18+
19+
## Tools used
20+
21+
This project is based on free tools that are available for Linux, MacOS, and
22+
Windows.
23+
It uses the small devices C compiler (SDCC) for compiling,
24+
[stm8flash](https://github.com/vdudouyt/stm8flash) for uploading the binary
25+
to the CPU, and simple Makefiles for the build process.
26+
27+
Support for the Cosmic compiler under Windows and integration into the ST
28+
visual developer IDE might be possible, but is not done (yet?).
29+
30+
The build process is controlled by a makefile based on the amazing
31+
[Arduino.mk makefile](https://github.com/sudar/Arduino-Makefile) by
32+
[Sudar](http://sudarmuthu.com>).
33+
1734

1835

1936

docs/api/LiquidCrystal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This library is a singleton library, it is not possible to use more than one
1111
instance per sketch.
1212

1313
The API syntax is very similar to the original C++ syntax, thanks to some
14-
[c preprocessor macro magic](../macro.md).
14+
[c preprocessor macro magic](../developer/macro).
1515

1616
Apart from the usual name mangeling for polymorph functions (mostly the
1717
different variants of the Print::print method) moving the opening bracket at

docs/api/PCD8544.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ from Adafruit (no sduino/STM8 port yet, though).
2727
## API
2828

2929

30-
Thanks to some [c preprocessor macro magic](../macro.md) the API syntax is
30+
Thanks to some [c preprocessor macro magic](../developer/macro) the API syntax is
3131
very similar to the original C++ syntax. Apart from the usual name mangeling
3232
for polymorph functions replacing the dots in the method names for
3333
underscores and a small modification of the initializer code should be

docs/api/Stepper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This library is a multi-instance library, it supports an arbitrary number of
1010
stepper motors per sketch.
1111

1212
The API syntax is very similar to the original C++ syntax, thanks to some
13-
[c preprocessor macro magic](../macro.md).
13+
[c preprocessor macro magic](../developer/macro).
1414

1515
The declaration supports polymorphism, so all that is needed to adopt an
1616
existing sketch for use with sduino is moving the opening bracket at

docs/contact.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# Contact
22

3-
For bug reports and other issues tightly related to the repository content
4-
please use the
3+
4+
### Bug reports and other issues tightly related to the repository
5+
56
[github issue tracker](https://github.com/tenbaht/sduino/issues).
67

7-
For general discussions and suggestions on Sduino it might be more
8-
convinient to open a thread on the
9-
[STM8 board](http://stm32duino.com/viewforum.php?f=52) of the stm32duino
10-
forum. It will help to catch my attention to prefix your topic with
11-
"[sduino]". (After registering on that forum, you are **required** to post
12-
an introduction in the new user board first in order to aquire the right to
13-
post or reply in any other board. Roger is strict on that.)
14-
15-
To send me an email please find my address in the commit messages of the
16-
repository (as a simple captcha test) or use the alias address
17-
8+
9+
### More general topics and suggestions
10+
11+
The [STM8 board](http://stm32duino.com/viewforum.php?f=52) of the
12+
stm32duino forum. It will help to catch my attention to prefix your topic
13+
with "[sduino]".
14+
15+
Please note that after registering on that forum, you are
16+
**required** to post an introduction in the new user board first in order to
17+
aquire the right to post or reply in any other board. Roger is strict on
18+
that.
19+
20+
21+
### email
22+
23+
Please find my address in the commit messages of the repository (as a simple
24+
captcha test) or use the alias address [email protected]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Bare metal programming
2+
3+
It all started by compiling some plain example programs without using any
4+
libraries. This avoids the code overhead of the Arduino libraries.
5+
6+
Lujji posted a [series of
7+
articles](https://lujji.github.io/blog/bare-metal-programming-stm8/) on bare
8+
metal programming of the STM8S CPUs. This is by far the best introduction I
9+
found so far. It would have helped me a lot if it would have been around at
10+
the time when I started this project.
11+
12+
13+
14+
15+
## Modifications for the sdcc example programs
16+
17+
I started my journey into the STM8 world with the
18+
[stm8-examples-sdcc](https://github.com/vdudouyt/sdcc-examples-stm8) by
19+
Valentin Dudouyt (vdudouyt), the author of
20+
[stm8flash](https://github.com/vdudouyt/stm8flash).
21+
22+
These examples are still part of the repository in
23+
examples/sdcc-examples-stm8. To compile for my STM8S103F3 board they
24+
required some modifications:
25+
26+
**blinky.c**: LED pin assignment
27+
28+
**uart.c**: pin assignment (TX is at PD5, RX is at PD6).
29+
The UART is sending at 1200 Baud => CPU clock only 2MHz instead of 16MHz.
30+
The clock divider needs to be configured or a different baud rate prescale value
31+
has to be used. Pitfall: The register address for the clock divider is
32+
different for the STM8S and the STM8L.
33+

docs/developer/links.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Links
2+
3+
## Further reading and application notes
4+
5+
[A series of
6+
articles](https://lujji.github.io/blog/bare-metal-programming-stm8/) on bare
7+
metal programming of the STM8S CPUs. By far the best introduction I
8+
found so far. It would have helped me a lot if it would have around at the
9+
time when I started this project.
10+
11+
[project documentation files](https://github.com/tenbaht/sduino/blob/master/docs/index.md)
12+
More in detail information about supported boards, tools and the API.
13+
14+
[Quick introduction to the Arduino.mk makefile]
15+
(http://hackaday.com/2015/10/01/arduino-development-theres-a-makefile-for-that/)
16+
17+
[PM0051](http://www.st.com/resource/en/programming_manual/cd00191343.pdf):
18+
STM8AF Flash programming manual
19+
[UM0470](http://www.st.com/resource/en/user_manual/cd00173911.pdf):
20+
STM8 SWIM protocol and debug manual
21+
[AN2658](http://www.st.com/resource/en/application_note/cd00176594.pdf):
22+
Using the analog-to-digital converter of the STM8S microcontroller
23+
24+
Many examples and presentations about the STM8S:
25+
https://github.com/VincentYChen/STM8teach
26+
It contains the SPL examples from ST, the most useful resource on the STM8:
27+
https://github.com/VincentYChen/STM8teach/tree/master/code/Project/STM8S_StdPeriph_Examples
28+
29+
Hardware and pinouts of several ST-Link compatible flash tools:
30+
https://wiki.cuvoodoo.info/doku.php?id=jtag
31+
32+
Using the ADC:
33+
http://blog.mark-stevens.co.uk/2012/09/single-scan-adc-on-the-stm8s/
34+
35+
Example for RS-232 handling with SPL:
36+
https://sourceforge.net/p/oggstreamer/oggs-stm8-firmware-001/ci/master/tree/rx_ringbuffer.c
37+
38+
[AN3139](http://www.st.com/resource/en/application_note/cd00262293.pdf):
39+
Migration guideline within the STM8L familiy
40+
41+
42+
43+
## Similar or related projects
44+
45+
None of these projects are related to or part of Sduino. They are written
46+
independently, but with a similar goal in mind: To simplify STM8 programming
47+
for the beginner.
48+
49+
[STM8Sduino](https://github.com/dannyf00/STM8Sduino): A minimalistic
50+
approach to adopt parts of the Arduino-API to the STM8. Based on IAR and
51+
COSMIC compiler (Windows only). Port to SDCC shouldn't be too hard but is
52+
not done yet. Low overhead, but basic functions only. No support for porting
53+
Arduino libraries.
54+
55+
56+
## Other interesting STM8-related projects
57+
58+
[gdb support for the STM8](https://stm8-binutils-gdb.sourceforge.io/)
59+
STM8 toolchain with GDB debugger and SDCC. Use the hardware debugging
60+
feature of the STM8 with ST-Link and gdb.
61+
62+
[STVD-SDCC integration suite](https://github.com/shkolnick-kun/stvd-sdcc)
63+

docs/macro.md renamed to docs/developer/macro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ As a result, there are several different cases to consider:
4141
The behaviour of this construction is very similar to a real C++ class.
4242

4343
**Examples:**
44-
[SPI](api/SPI.md), [I2C](api/I2C.md),
45-
[HardwareSerial](api/HardwareSerial.md)
44+
[SPI](../api/SPI.md), [I2C](../api/I2C.md),
45+
[HardwareSerial](../api/HardwareSerial.md)
4646

4747
```c
4848
#include <I2C.h>
@@ -77,7 +77,7 @@ setup() {
7777
Polymorph instantiation declarations are possible.
7878
Non-constant values for the initialization are supported.
7979

80-
**Examples:** [LiquidCrystal](api/LiquidCrystal.md)
80+
**Examples:** [LiquidCrystal](../api/LiquidCrystal.md)
8181

8282
```c
8383
int rs_pin = 2;
@@ -116,7 +116,7 @@ setup() {
116116
117117
Polymorph instantiation declarations are possible.
118118
119-
Examples: [Servo](api/Servo.md)
119+
Examples: [Servo](../api/Servo.md)
120120
121121
```c
122122
#include <Servo.h>
@@ -178,7 +178,7 @@ loop() {
178178

179179
Polymorph instantiation declarations are possible.
180180

181-
Examples: [Stepper](api/Stepper.md)
181+
Examples: [Stepper](../api/Stepper.md)
182182

183183
By requiring the user to add a call to the added constructor as the
184184
mandatory first call to the instance it could be treated as any other

docs/developer/performance.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Performance
2+
3+
The STM8 backend for SDCC has improved a lot since the release of version
4+
3.6.0 in June 2016. But due to the very small number of registers the code
5+
size will almost always be bigger than for the AVR. Depending on the exact
6+
application the difference is anywhere between negligible and factor two.
7+
8+
9+
10+
## Comparing code size with the original AVR Arduino
11+
12+
Benchmarking the original Arduino examples from Arduino 1.0.5. The simple
13+
Blinky compiles to 57 bytes of code, the total binary including the sduino
14+
libraries is 1868 Bytes (0x74c).
15+
16+
So far, wiring_analog depends on wiring_digital, even when analogWrite is not
17+
used. This could be solved by compiling the sduino functions separately into
18+
a library.
19+
20+
|Name |Code |Total |Linked files other than main and wiring
21+
|--------------------- |------ |----- |-----------------------------
22+
|01. Basics/ |
23+
|BareMinimum |2 |1238 |-
24+
|Blink |57 |1870 |wiring_digital
25+
|AnalogReadSerial |205 |3452 |digital, analog, serial, print
26+
|DigitalReadSerial |57 |3160 |digital, serial, print
27+
|Fade |226 |2189 |digital, analog
28+
|ReadAnalogVoltage | | |float not yet implemented
29+
|02. Digital/ |
30+
|Debounce |192 |2016 |digital
31+
32+
33+
## Float arithmetics
34+
35+
Floating point arithmetics is supported by the SDCC standard library, but it
36+
comes at a pretty high cost in terms of code space and CPU load. This is how
37+
much the generated code grows by using a single float operation compared to
38+
using a long int:
39+
40+
Floating point operation |approx. code size
41+
-------------------- |---------
42+
addition | 736 Bytes
43+
subtraction | 754 Bytes
44+
division | 673 Bytes
45+
multiplication | 907 Bytes
46+
sinf() or cosf() | 3346 Bytes
47+
log10f() | 3437 Bytes
48+
49+
The Arduino standard example '01. Basics/ReadAnalogVoltage' is a very simple
50+
simple program with only very little floating point arithmetics. But it
51+
already uses 7336 bytes of flash. A similar sketch using integer arithmetics
52+
results in much more compact code occuping only 3791 bytes.
53+
54+
Float does work, but is better to be avoided and replaced by fixed point
55+
arithmetics whenever possible.

0 commit comments

Comments
 (0)