2017-09-21 06:05 AM
\ Trying to trim HSI I get 3 identical lowest frequencies verified on scope
\ eForth on STM8S103F running MINDEV
\
https://github.com/TG9541/stm8ef
\
http://forum.hobbycomponents.com/viewtopic.php?f=87&t=2180
\ my contrib under user barewires
\ initTIM1 and content from previous page 1
\ 1st try trim freq and confirm register readback at 4 kHz
\
FILENVM: CLK_HSITRIMR $50CC ;: f3 3 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999 lowest freq ?: f2 2 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999 ?: f1 1 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 3.999 ?: f0 0 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.04 kHz reset value: f7 7 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.087: f6 6 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.123: f5 5 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.18: f4 4 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 4.229 highest freqRAMHANDinitTIM14000 Hzf3 3 ok2017-09-22 12:57 AM
\ Updated tests now work but on another device.
\ contents of HSI.f
\ 1st try trim freq and confirm register readback at 16 kHzFILENVM: CLK_HSITRIMR $50CC ;: f3 3 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.45 lowest freq : f2 2 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.52 : f1 1 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.70: f0 0 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 15.87 kHz reset value: f7 7 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.05: f6 6 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.24: f5 5 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.43: f4 4 CLK_HSITRIMR C! CLK_HSITRIMR C@ . ; \ 16.62 highest freq: cc $50C0 $F dump ;RAMHANDinitTIM116000 Hzf3 <enter> 3 okThree-bit two's-complement integers
Bits Unsigned value Two's complement value011 3  3 010 2  2 001 1  1 000 0  0 111 7  −1 110 6  −2 101 5  −3 100 4  −4 2017-09-22 01:12 PM
Here is the code: