Skip to content

Instantly share code, notes, and snippets.

View TG9541's full-sized avatar

Thomas TG9541

View GitHub Profile
@TG9541
TG9541 / Clrdisplay.fs
Last active July 22, 2017 07:19
STM8EF Snippets
: Clrdisplay ( -- ) \ clear anything showing
32 E7S 32 E7S 32 E7S ;
@TG9541
TG9541 / servo.fs
Last active November 17, 2017 05:48
STM8S103F3 RC servo control
\ STM8 eForth interactive RC-servo demo
\ set compilation target for STARTTEMP / ENDTEMP
: TARGET NVM ;
#require hw/pwm.fs
#require OPT!
#include STARTTEMP
@TG9541
TG9541 / ECHO
Created February 3, 2018 08:29
Make local echo in STM8 eForth optional
\ STM8 eForth ECHO
\ Make local echo in STM8 eForth optional
\ Note1: since this code patches TAP, and sets the startup word,
\ it should be loaded with #require ECHO
\ Note2: the RAM address of variable TAPECHO must be below 0x0100,
\ it's recommended to #require ECHO early on in the main file
\ Note3: this file sets the 'BOOT vector for initializing TAPECHO -
\ any startup code must execute this task!
#require TAP
@TG9541
TG9541 / GET
Created February 3, 2018 09:37
GET and print variable as fixed point in STM8 eForth interpreter
RAM
#require TOKEN
#require >IN
#require .ID
#require .0
NVM
: GET ( string -- )
\ interpretion semantics: get and print variable
>IN @ TOKEN CR .ID ." ="
>IN ! ' EXECUTE
@TG9541
TG9541 / globconf.inc
Created March 27, 2018 20:49
EECORE global configuration for STM8 eForth v2.2.22.pre
; STM8EF Global Configuration File
; Minimal config for STM8S Value Line, defaults with few extras (e.g. NVM)
HAS_CPNVM = 1 ; Can compile to Flash, always interpret to RAM
BAREBONES = 1 ; Remove or unlink some more: hi HERE .R U.R SPACES @EXECUTE AHEAD CALL, EXIT COMPILE [COMPILE]
WORDS_EXTRACORE = 1 ; Extra core words: =0 I
WORDS_EXTRAEEPR = 1 ; Extra EEPROM lock/unlock words: LOCK ULOCK ULOCKF LOCKF
; RESET RAM NVM LOCK ULOCK WORDS .S DUMP IMMEDIATE ALLOT VARIABLE CONSTANT CREATE ] : ;
; OVERT ." AFT REPEAT WHILE ELSE THEN IF AGAIN UNTIL BEGIN NEXT FOR LITERAL C, , ' CR [
@TG9541
TG9541 / EEALL.fs
Last active April 16, 2018 18:52
ALIAS loader for STM8S003F3 EECORE dictionary demo
#require <#
\ #require $,"
#require $"
\ #require $"|
#require #
#require #>
\ #require 0
\ #require 1
\ #require -1
#require 2DROP
@TG9541
TG9541 / free.fs
Created June 18, 2018 21:14
get free memory in the RAM dictionary, and in the variable area
#require PAD
: SP@ ( -- a ) \ push current stack pointer
[ $9093 , \ LDW Y,X
$5A C, \ DECW X
$5A C, \ DECW X
$FF C, ] \ LDW (X),Y
;
: dict.free SP@ PAD - . ;
@TG9541
TG9541 / solar.fs
Last active September 24, 2018 18:52
Simple solar heating controller based on a MINDEV board
\res MCU: STM8S103
\res export PA_ODR
\res export PA_DDR
\res export PA_CR1
\res export PC_DDR
\res export PC_CR1
#require ]B!
1 CONSTANT _COL \ PA1 low side KTY10 solar collector
@TG9541
TG9541 / solboard.md
Created October 28, 2018 09:01
STM8SxxxKyT6C port assignment
Pin STM	Connected to
-------------------------------------
 1  NRST
 2  PA1        (Y1)
 3  PA2        (Y1)
 4  VSS        digital ground
 5  VCAP       (C)
 6  VDD        power supply
 7 AE3(VDDIO) AE3 (I/O power supply)
@TG9541
TG9541 / C0135-MODBUS-RTU.md
Last active December 21, 2018 17:39
C0135 MODBUS RTU Examples

Examples

Do not provide source communication MODBUS code

MODBUS RTU communication instruction:

Modbus RTU instruction

Baud rate: 96008 NONE 1