Skip to main content
Visitor II
September 21, 2017
Question

STM8S HSI Calibration errors

  • September 21, 2017
  • 1 reply
  • 774 views
Posted on September 21, 2017 at 15:05

\ 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

\

FILE

NVM

: 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 freq

RAM

HAND

initTIM1

4000 Hz

f3 3 ok
    This topic has been closed for replies.

    1 reply

    Visitor II
    September 22, 2017
    Posted on September 22, 2017 at 09:57

    \ Updated tests now work but on another device.

    \ contents of HSI.f

    \ 1st try trim freq and confirm register readback at 16 kHzFILE

    NVM

    : 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 ;

    RAM

    HAND

    initTIM1

    16000 Hz

    f3 <enter> 3 ok

    Three-bit two's-complement integers

    Bits Unsigned value Two's complement value

    011 3  3 

    010 2  2 

    001 1  1 

    000 0  0 

    111 7  −1 

    110 6  −2 

    101 5  −3 

    100 4  −4 

    https://en.wikipedia.org/wiki/Two%27s_complement

    Visitor II
    September 22, 2017
    Posted on September 22, 2017 at 20:12

    Here is the code:

    https://github.com/TG9541/stm8ef/issues/64