Skip to content

Commit

Permalink
#358: STM8L High Density added
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Oct 9, 2020
1 parent c045bc8 commit 2b5173c
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 21 deletions.
33 changes: 12 additions & 21 deletions STM8L151K4/README.md
Expand Up @@ -4,27 +4,18 @@ This folder contains support for STM8L Medium Density devices like [STM8L151K4](

STM8L151K4 stands for "Medium density" devices with 2K RAM, 1K EEPROM and up to 32K Flash ROM as described in [RM0031](https://www.st.com/resource/en/reference_manual/cd00218714-stm8l050j3-stm8l051f3-stm8l052c6-stm8l052r8-mcus-and-stm8l151l152-stm8l162-stm8al31-stm8al3l-lines-stmicroelectronics.pdf) (or "32 Kbyte die" as described in [UM0470](https://www.st.com/content/ccc/resource/technical/document/user_manual/ca/89/41/4e/72/31/49/f4/CD00173911.pdf/files/CD00173911.pdf/jcr:content/translations/en.CD00173911.pdf)), all of which should work with the STM8L151K4 binary in the Releases section (likely it's also usable for Automotive Grade STM8L Medium Density devices).


"Medium+" or "High Density" devices described in RM0031 (e.g. STM8L052R8) have, besides more peripherals, 4K RAM and require different RAM settings in `target.inc`. If you have e.g. a NUCLEO-8L152R8 you may want to try the following settings:

```
; STM8L152R8 device and memory layout configuration
TARGET = STM8L152R8
RAMEND = 0x0FFF ; "RAMEND" system (return) stack, growing down
EEPROMBASE = 0x1000 ; "EESTART" EEPROM start address
EEPROMEND = 0x17FF ; "EEEND" 2K EEPROM
FLASHEND = 0xFFFF ; 32K Forth + 32K far memory
FORTHRAM = 0x0030 ; Start of RAM controlled by Forth
UPPLOC = 0x0060 ; UPP (user/system area) location for 4K RAM
CTOPLOC = 0x0080 ; CTOP (user dictionary) location for 4K RAM
SPPLOC = 0x0f50 ; SPP (data stack top), TIB start
RPPLOC = RAMEND ; RPP (return stack top)
```

The default USART for the Forth console is USART1. That can be changed by setting `USE_USART2 = 1` or `USE_USART3 = 1` in `globconf.inc`. Peripheral register addresses are likely the same and constants imported from `\res MCU: STM8L151` should work. Of course, we'd be happy to hear from you if it works (or help fixing it if it doesn't).
![image](https://user-images.githubusercontent.com/5466977/95546354-ab96da00-0a00-11eb-9907-5e89812284ff.png)

Pin|GPIO|Function
-|-|-
32|PA0|SWIM
1|PA1|NRST
2|PA2|[USART1_TX]
3|PA3|[USART1_RX]
27|PC2|USART1_RX
28|PC3|USART1_TX

High Density devices as described in RM0031 (e.g. STM8L152R8) have more memory and a richer set of peripherals. Using the [STM8L152R8](https://github.com/TG9541/stm8ef/tree/master/STM8L152R8) binary is recommended.

Low Density devices described in RM0031 (e.g. STM8L051), RM0013 (e.g. STM8L101) or RM0312 (STM8TL5xxx) use different peripheral register addresses and have a different memory layout. These require a different binary.

Expand Down
42 changes: 42 additions & 0 deletions STM8L152R8/README.md
@@ -0,0 +1,42 @@
# STM8L151K4 Base Image

This folder contains experimental support for STM8L High Density devices like [STM8L151x8/152x8](https://www.st.com/resource/en/datasheet/stm8l152r8.pdf) or the identical (but lower specs "Value Line") [STM8L052R8](https://www.st.com/resource/en/datasheet/stm8l052r8.pdf). Medium+ Density devices (e.g. STM8L15xR6) look suspiciously similar to High Density devices since the set of peripherals is identical (but the specified amount of RAM and EEPROM might indeed be like that of Medium density devices - best you try it and make adjustments in `target.inc` as needed - feedback is always welcome!).

STM8L152R8 stands for "High Density" devices with 4K RAM, 2K EEPROM and up to 64K Flash ROM as described in [RM0031](https://www.st.com/resource/en/reference_manual/cd00218714-stm8l050j3-stm8l051f3-stm8l052c6-stm8l052r8-mcus-and-stm8l151l152-stm8l162-stm8al31-stm8al3l-lines-stmicroelectronics.pdf). All variants should work with the STM8L151K4 binary in the Releases section (likely it's also usable for Automotive Grade STM8L High Density devices).
```
; STM8L152R8 device and memory layout configuration
TARGET = STM8L152R8
RAMEND = 0x0FFF ; "RAMEND" system (return) stack, growing down
EEPROMBASE = 0x1000 ; "EESTART" EEPROM start address
EEPROMEND = 0x17FF ; "EEEND" 2K EEPROM
FLASHEND = 0xFFFF ; 32K Forth + 32K far memory
FORTHRAM = 0x0030 ; Start of RAM controlled by Forth
UPPLOC = 0x0060 ; UPP (user/system area) location for 4K RAM
CTOPLOC = 0x0080 ; CTOP (user dictionary) location for 4K RAM
SPPLOC = 0x0f50 ; SPP (data stack top), TIB start
RPPLOC = RAMEND ; RPP (return stack top)
```

The default USART for the Forth console is USART1. That can be changed by setting `USE_UART2 = 1` or `USE_UART3 = 1` in `globconf.inc`. Peripheral register addresses are likely the same and constants imported from `\res MCU: STM8L151` should work. Of course, we'd be happy to hear from you if it works (or help fixing it if it doesn't).

![image](https://user-images.githubusercontent.com/5466977/95511446-c7c25900-09b7-11eb-8bc4-69e407a58602.png)

Pin|GPIO|Function
-|-|-
1|PA0|SWIM
2|PA1|NRST
3|PA2|[USART1_TX]
4|PA3|[USART1_RX]
14|PG0|USART3_RX
15|PG1|USART3_TX
22|PE3|USART2_RX
23|PE4|USART2_TX
39|PF0|[USART3_TX]
40|PF1|[USART3_RX]
57|PC2|USART1_RX
58|PC3|USART1_TX

LCD support is from @plumbum 's work for the [STM8L-DISCOVERY](https://github.com/TG9541/stm8ef/tree/master/STM8L-DISCOVERY) - it's provided as-is and it's currently disabled in `globconf.inc` and untested.

0 comments on commit 2b5173c

Please sign in to comment.