Library functions, and the upload utility in e4thcom with its #include feature make programming a STM8S103F3 demo board much simpler.
Here is an example:
#include utils/rammark.fs RAMmark #include regs/opt.fs NVM #include hw/opt.fs \ set option bits to enable PC5 TIM1_CC1, and PC6 TIM1_CC2 : OptInit ( -- ) OPT2 DUP C@ $01 OR SWAP OPT! ; RAMdrop RAMmark #include regs/timer1.fs NVM #include hw/pwm.fs \ timer1 init to 1MHz clock and 20ms period : ServoInit ( -- ) 15 T1PwmInit 20000 T1Reload 1500 PWM1 \ PC6 pin 16 1500 PWM2 \ PC5 pin 15 1500 PWM3 \ PC3 pin 13 ; RAMdrop \ Done! \ run OptInit to configure GPIO functions **once** \ run ServoInit \ set servos with y PWMx | y: 1000..2000 [µs], x: 1..3
This demo works with STM8EF v2.2.13.snapshot (the include files are in the lib folder).
Steps for using it:
- unpack the v2.2.13.snapshot binary
- put servo.fs into the release base folder
- install e4thcom, and put the e4thcom STM8EF extension into the release base folder
- run e4thcom with e4thcom-0.6.1 -t stm8ef -d ttyUSB0 (or whatever your TTY is)
- in e4thcom type #i servo.fs
- follow the instructions in the last comment lines (run means 'type and press enter' :-) )
Refer to the e4thcom docs for more information.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.